1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include "ChartController.hxx"
30 #include "servicenames.hxx"
32 #include "dlg_DataSource.hxx"
33 #include "ChartModelHelper.hxx"
34 #include "ControllerCommandDispatch.hxx"
35 #include "Strings.hrc"
36 #include "chartview/ExplicitValueProvider.hxx"
37 #include "ChartViewHelper.hxx"
39 #include "ChartWindow.hxx"
40 #include "chartview/DrawModelWrapper.hxx"
41 #include "DrawViewWrapper.hxx"
42 #include "ObjectIdentifier.hxx"
43 #include "DiagramHelper.hxx"
44 #include "ControllerLockGuard.hxx"
45 #include "UndoGuard.hxx"
46 #include "ChartDropTargetHelper.hxx"
49 #include "dlg_CreationWizard.hxx"
50 #include "dlg_ChartType.hxx"
51 #include "AccessibleChartView.hxx"
52 #include "DrawCommandDispatch.hxx"
53 #include "ShapeController.hxx"
54 #include "UndoActions.hxx"
56 #include <comphelper/InlineContainer.hxx>
58 #include <com/sun/star/awt/PosSize.hpp>
59 #include <com/sun/star/chart2/XChartDocument.hpp>
60 #include <com/sun/star/chart2/data/XDataReceiver.hpp>
61 #include <com/sun/star/frame/XLoadable.hpp>
62 #include <com/sun/star/util/XCloneable.hpp>
63 #include <com/sun/star/embed/XEmbeddedClient.hpp>
64 #include <com/sun/star/util/XModeChangeBroadcaster.hpp>
65 #include <com/sun/star/util/XModifyBroadcaster.hpp>
66 #include <com/sun/star/frame/LayoutManagerEvents.hpp>
67 #include <com/sun/star/document/XUndoManagerSupplier.hpp>
68 #include <com/sun/star/document/XUndoAction.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 <osl/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>
88 #include <tools/diagnose_ex.h>
90 // enable the following define to let the controller listen to model changes and
91 // react on this by rebuilding the view
92 #define TEST_ENABLE_MODIFY_LISTENER
94 //.............................................................................
97 //.............................................................................
99 using namespace ::com::sun::star
;
100 using namespace ::com::sun::star::accessibility
;
101 using namespace ::com::sun::star::chart2
;
102 using ::com::sun::star::uno::Any
;
103 using ::com::sun::star::uno::Reference
;
104 using ::com::sun::star::uno::Sequence
;
105 DBG_NAME(ChartController
)
106 //-----------------------------------------------------------------
107 // ChartController Constructor and Destructor
108 //-----------------------------------------------------------------
110 ChartController::ChartController(uno::Reference
<uno::XComponentContext
> const & xContext
)
111 : m_aLifeTimeManager( NULL
)
112 , m_bSuspended( sal_False
)
113 , m_bCanClose( sal_True
)
114 , m_xCC(xContext
) //@todo is it allowed to hold this context??
117 , m_aModel( NULL
, m_aModelMutex
)
118 , m_pChartWindow( NULL
)
121 , m_pDrawModelWrapper()
122 , m_pDrawViewWrapper(NULL
)
123 , m_eDragMode(SDRDRAG_MOVE
)
124 , m_bWaitingForDoubleClick(false)
125 , m_bWaitingForMouseUp(false)
126 , m_bConnectingToView(false)
127 , m_xUndoManager( 0 )
128 , m_aDispatchContainer( m_xCC
, this )
129 , m_eDrawMode( CHARTDRAW_SELECT
)
131 DBG_CTOR(ChartController
,NULL
);
132 m_aDoubleClickTimer
.SetTimeoutHdl( LINK( this, ChartController
, DoubleClickWaitingHdl
) );
135 ChartController::~ChartController()
137 DBG_DTOR(ChartController
,NULL
);
138 stopDoubleClickWaiting();
141 //-----------------------------------------------------------------
143 ChartController::RefCountable::RefCountable() : m_nRefCount(0)
147 ChartController::RefCountable::~RefCountable()
150 void ChartController::RefCountable::acquire()
154 void ChartController::RefCountable::release()
161 //-----------------------------------------------------------------
163 ChartController::TheModel::TheModel( const uno::Reference
< frame::XModel
> & xModel
)
165 , m_xCloseable( NULL
)
166 , m_bOwnership( sal_True
)
167 , m_bOwnershipIsWellKnown( sal_False
)
170 uno::Reference
< util::XCloseable
>( xModel
, uno::UNO_QUERY
);
173 ChartController::TheModel::~TheModel()
177 void ChartController::TheModel::SetOwnerShip( sal_Bool bGetsOwnership
)
179 m_bOwnership
= bGetsOwnership
;
180 m_bOwnershipIsWellKnown
= sal_True
;
183 void ChartController::TheModel::addListener( ChartController
* pController
)
185 if(m_xCloseable
.is())
187 //if you need to be able to veto against the destruction of the model
188 // you must add as a close listener
190 //otherwise you 'can' add as closelistener or 'must' add as dispose event listener
192 m_xCloseable
->addCloseListener(
193 static_cast<util::XCloseListener
*>(pController
) );
195 else if( m_xModel
.is() )
197 //we need to add as dispose event listener
198 m_xModel
->addEventListener(
199 static_cast<util::XCloseListener
*>(pController
) );
204 void ChartController::TheModel::removeListener( ChartController
* pController
)
206 if(m_xCloseable
.is())
207 m_xCloseable
->removeCloseListener(
208 static_cast<util::XCloseListener
*>(pController
) );
210 else if( m_xModel
.is() )
211 m_xModel
->removeEventListener(
212 static_cast<util::XCloseListener
*>(pController
) );
215 void ChartController::TheModel::tryTermination()
222 if(m_xCloseable
.is())
226 //@todo ? are we allowed to use sal_True here if we have the explicit ownership?
227 //I think yes, because there might be other closelistners later in the list which might be interested still
228 //but make sure that we do not throw the CloseVetoException here ourselfs
229 //so stop listening before trying to terminate or check the source of queryclosing event
230 m_xCloseable
->close(sal_True
);
232 m_bOwnership
= false;
233 m_bOwnershipIsWellKnown
= sal_True
;
235 catch( const util::CloseVetoException
& )
237 //since we have indicated to give up the ownership with paramter true in close call
238 //the one who has thrown the CloseVetoException is the new owner
240 #if OSL_DEBUG_LEVEL > 1
241 OSL_ENSURE( !m_bOwnership
,
242 "INFO: a well known owner has caught a CloseVetoException after calling close(true)" );
245 m_bOwnership
= false;
246 m_bOwnershipIsWellKnown
= sal_True
;
251 else if( m_xModel
.is() )
258 catch(const uno::Exception
& ex
)
260 (void)(ex
); // no warning in non-debug builds
261 OSL_FAIL( ( rtl::OString("Termination of model failed: ")
262 + rtl::OUStringToOString( ex
.Message
, RTL_TEXTENCODING_ASCII_US
) ).getStr() );
266 //-----------------------------------------------------------------
268 ChartController::TheModelRef::TheModelRef( TheModel
* pTheModel
, ::osl::Mutex
& rMutex
)
269 : m_pTheModel(pTheModel
), m_rModelMutex(rMutex
)
271 ::osl::Guard
< ::osl::Mutex
> aGuard( m_rModelMutex
);
273 m_pTheModel
->acquire();
275 ChartController::TheModelRef::TheModelRef( const TheModelRef
& rTheModel
, ::osl::Mutex
& rMutex
)
276 : m_rModelMutex(rMutex
)
278 ::osl::Guard
< ::osl::Mutex
> aGuard( m_rModelMutex
);
279 m_pTheModel
=rTheModel
.operator->();
281 m_pTheModel
->acquire();
283 ChartController::TheModelRef
& ChartController::TheModelRef::operator=(TheModel
* pTheModel
)
285 ::osl::Guard
< ::osl::Mutex
> aGuard( m_rModelMutex
);
286 if(m_pTheModel
==pTheModel
)
289 m_pTheModel
->release();
290 m_pTheModel
=pTheModel
;
292 m_pTheModel
->acquire();
295 ChartController::TheModelRef
& ChartController::TheModelRef::operator=(const TheModelRef
& rTheModel
)
297 ::osl::Guard
< ::osl::Mutex
> aGuard( m_rModelMutex
);
298 TheModel
* pNew
=rTheModel
.operator->();
299 if(m_pTheModel
==pNew
)
302 m_pTheModel
->release();
305 m_pTheModel
->acquire();
308 ChartController::TheModelRef::~TheModelRef()
310 ::osl::Guard
< ::osl::Mutex
> aGuard( m_rModelMutex
);
312 m_pTheModel
->release();
314 sal_Bool
ChartController::TheModelRef::is() const
316 return (m_pTheModel
!= 0);
320 //-----------------------------------------------------------------
322 //-----------------------------------------------------------------
324 sal_Bool ChartController
325 ::impl_isDisposedOrSuspended() const
327 if( m_aLifeTimeManager
.impl_isDisposed() )
332 OSL_FAIL( "This Controller is suspended" );
338 //-----------------------------------------------------------------
339 // lang::XServiceInfo
340 //-----------------------------------------------------------------
342 APPHELPER_XSERVICEINFO_IMPL(ChartController
,CHART_CONTROLLER_SERVICE_IMPLEMENTATION_NAME
)
344 uno::Sequence
< rtl::OUString
> ChartController
345 ::getSupportedServiceNames_Static()
347 uno::Sequence
< rtl::OUString
> aSNS( 2 );
348 aSNS
.getArray()[ 0 ] = CHART_CONTROLLER_SERVICE_NAME
;
349 aSNS
.getArray()[ 1 ] = ::rtl::OUString( "com.sun.star.frame.Controller" );
350 //// @todo : add additional services if you support any further
354 //-----------------------------------------------------------------
356 //-----------------------------------------------------------------
358 void SAL_CALL ChartController
359 ::attachFrame( const uno::Reference
<frame::XFrame
>& xFrame
)
360 throw(uno::RuntimeException
)
362 SolarMutexGuard aGuard
;
364 if( impl_isDisposedOrSuspended() ) //@todo? allow attaching the frame while suspended?
365 return; //behave passive if already disposed or suspended
367 if(m_xFrame
.is()) //what happens, if we do have a Frame already??
369 //@todo? throw exception?
370 OSL_FAIL( "there is already a frame attached to the controller" );
375 m_xFrame
= xFrame
; //the frameloader is responsible to call xFrame->setComponent
377 //add as disposelistener to the frame (due to persistent reference) ??...:
379 //the frame is considered to be owner of this controller and will live longer than we do
380 //the frame or the disposer of the frame has the duty to call suspend and dispose on this object
381 //so we do not need to add as lang::XEventListener for DisposingEvents right?
383 //@todo nothing right???
387 //--------------------------------------------------
388 //create view @todo is this the correct place here??
390 Window
* pParent
= NULL
;
391 //get the window parent from the frame to use as parent for our new window
394 uno::Reference
< awt::XWindow
> xContainerWindow
= xFrame
->getContainerWindow();
395 VCLXWindow
* pParentComponent
= VCLXWindow::GetImplementation(xContainerWindow
);
396 pParentComponent
->setVisible(sal_True
);
398 pParent
= VCLUnoHelper::GetWindow( xContainerWindow
);
404 m_pChartWindow
->clear();
405 m_apDropTargetHelper
.reset();
408 awt::Size
aPageSize( ChartModelHelper::getPageSize(getModel()) );
411 SolarMutexGuard aSolarGuard
;
412 m_pChartWindow
= new ChartWindow(this,pParent
,pParent
?pParent
->GetStyle():0);
413 m_pChartWindow
->SetBackground();//no Background
414 m_xViewWindow
= uno::Reference
< awt::XWindow
>( m_pChartWindow
->GetComponentInterface(), uno::UNO_QUERY
);
415 m_pChartWindow
->Show();
416 m_apDropTargetHelper
.reset(
417 new ChartDropTargetHelper( m_pChartWindow
->GetDropTarget(),
418 uno::Reference
< chart2::XChartDocument
>( getModel(), uno::UNO_QUERY
)));
420 impl_createDrawViewController();
425 uno::Reference
< beans::XPropertySet
> xPropSet( xFrame
, uno::UNO_QUERY
);
430 uno::Reference
< ::com::sun::star::frame::XLayoutManager
> xLayoutManager
;
431 xPropSet
->getPropertyValue( C2U( "LayoutManager" ) ) >>= xLayoutManager
;
432 if ( xLayoutManager
.is() )
434 xLayoutManager
->lock();
435 xLayoutManager
->requestElement( C2U( "private:resource/menubar/menubar" ) );
436 //@todo: createElement should become unnecessary, remove when #i79198# is fixed
437 xLayoutManager
->createElement( C2U( "private:resource/toolbar/standardbar" ) );
438 xLayoutManager
->requestElement( C2U( "private:resource/toolbar/standardbar" ) );
439 //@todo: createElement should become unnecessary, remove when #i79198# is fixed
440 xLayoutManager
->createElement( C2U( "private:resource/toolbar/toolbar" ) );
441 xLayoutManager
->requestElement( C2U( "private:resource/toolbar/toolbar" ) );
443 // #i12587# support for shapes in chart
444 xLayoutManager
->createElement( C2U( "private:resource/toolbar/drawbar" ) );
445 xLayoutManager
->requestElement( C2U( "private:resource/toolbar/drawbar" ) );
447 xLayoutManager
->requestElement( C2U( "private:resource/statusbar/statusbar" ) );
448 xLayoutManager
->unlock();
450 // add as listener to get notified when
451 m_xLayoutManagerEventBroadcaster
.set( xLayoutManager
, uno::UNO_QUERY
);
452 if( m_xLayoutManagerEventBroadcaster
.is())
453 m_xLayoutManagerEventBroadcaster
->addLayoutManagerEventListener( this );
456 catch( const uno::Exception
& ex
)
458 ASSERT_EXCEPTION( ex
);
464 //XModeChangeListener
465 void SAL_CALL
ChartController::modeChanged( const util::ModeChangeEvent
& rEvent
)
466 throw ( uno::RuntimeException
)
468 //adjust controller to view status changes
470 if( rEvent
.NewMode
.equals(C2U("dirty")) )
472 //the view has become dirty, we should repaint it if we have a window
473 SolarMutexGuard aGuard
;
475 m_pChartWindow
->ForceInvalidate();
477 else if( rEvent
.NewMode
.equals(C2U("invalid")) )
479 //the view is about to become invalid so end all actions on it
480 impl_invalidateAccessible();
481 SolarMutexGuard aGuard
;
482 if( m_pDrawViewWrapper
&& m_pDrawViewWrapper
->IsTextEdit() )
484 if( m_pDrawViewWrapper
)
486 m_pDrawViewWrapper
->UnmarkAll();
487 m_pDrawViewWrapper
->HideSdrPage();
492 //the view was rebuild so we can start some actions on it again
493 if( !m_bConnectingToView
)
495 if(m_pChartWindow
&& m_aModel
.is() )
497 m_bConnectingToView
= true;
499 GetDrawModelWrapper();
500 if(m_pDrawModelWrapper
)
503 SolarMutexGuard aGuard
;
504 if( m_pDrawViewWrapper
)
505 m_pDrawViewWrapper
->ReInit();
509 if( m_aSelection
.hasSelection() )
510 this->impl_selectObjectAndNotiy();
512 ChartModelHelper::triggerRangeHighlighting( getModel() );
514 impl_initializeAccessible();
517 SolarMutexGuard aGuard
;
519 m_pChartWindow
->Invalidate();
523 m_bConnectingToView
= false;
529 sal_Bool SAL_CALL
ChartController::attachModel( const uno::Reference
< frame::XModel
> & xModel
)
530 throw(uno::RuntimeException
)
532 impl_invalidateAccessible();
534 //is called to attach the controller to a new model.
535 //return true if attach was successfully, false otherwise (e.g. if you do not work with a model)
537 SolarMutexClearableGuard aClearableGuard
;
538 if( impl_isDisposedOrSuspended() ) //@todo? allow attaching a new model while suspended?
539 return sal_False
; //behave passive if already disposed or suspended
540 aClearableGuard
.clear();
542 TheModelRef
aNewModelRef( new TheModel( xModel
), m_aModelMutex
);
543 TheModelRef
aOldModelRef(m_aModel
,m_aModelMutex
);
544 m_aModel
= aNewModelRef
;
546 //--handle relations to the old model if any
547 if( aOldModelRef
.is() )
549 uno::Reference
< util::XModeChangeBroadcaster
> xViewBroadcaster( m_xChartView
, uno::UNO_QUERY
);
550 if( xViewBroadcaster
.is() )
551 xViewBroadcaster
->removeModeChangeListener(this);
552 m_pDrawModelWrapper
.reset();
554 aOldModelRef
->removeListener( this );
555 #ifdef TEST_ENABLE_MODIFY_LISTENER
556 uno::Reference
< util::XModifyBroadcaster
> xMBroadcaster( aOldModelRef
->getModel(),uno::UNO_QUERY
);
557 if( xMBroadcaster
.is())
558 xMBroadcaster
->removeModifyListener( this );
562 //--handle relations to the new model
563 aNewModelRef
->addListener( this );
565 // set new model at dispatchers
566 m_aDispatchContainer
.setModel( aNewModelRef
->getModel());
567 ControllerCommandDispatch
* pDispatch
= new ControllerCommandDispatch( m_xCC
, this, &m_aDispatchContainer
);
568 pDispatch
->initialize();
570 // the dispatch container will return "this" for all commands returned by
571 // impl_getAvailableCommands(). That means, for those commands dispatch()
572 // is called here at the ChartController.
573 m_aDispatchContainer
.setChartDispatch( pDispatch
, impl_getAvailableCommands() );
575 DrawCommandDispatch
* pDrawDispatch
= new DrawCommandDispatch( m_xCC
, this );
578 pDrawDispatch
->initialize();
579 m_aDispatchContainer
.setDrawCommandDispatch( pDrawDispatch
);
582 ShapeController
* pShapeController
= new ShapeController( m_xCC
, this );
583 if ( pShapeController
)
585 pShapeController
->initialize();
586 m_aDispatchContainer
.setShapeController( pShapeController
);
589 #ifdef TEST_ENABLE_MODIFY_LISTENER
590 uno::Reference
< util::XModifyBroadcaster
> xMBroadcaster( aNewModelRef
->getModel(),uno::UNO_QUERY
);
591 if( xMBroadcaster
.is())
592 xMBroadcaster
->addModifyListener( this );
595 //select chart area per default:
596 select( uno::makeAny( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_PAGE
, rtl::OUString() ) ) );
598 uno::Reference
< lang::XMultiServiceFactory
> xFact( getModel(), uno::UNO_QUERY
);
601 m_xChartView
= xFact
->createInstance( CHART_VIEW_SERVICE_NAME
);
602 GetDrawModelWrapper();
603 uno::Reference
< util::XModeChangeBroadcaster
> xViewBroadcaster( m_xChartView
, uno::UNO_QUERY
);
604 if( xViewBroadcaster
.is() )
605 xViewBroadcaster
->addModeChangeListener(this);
608 //the frameloader is responsible to call xModel->connectController
610 SolarMutexGuard aGuard
;
612 m_pChartWindow
->Invalidate();
615 uno::Reference
< document::XUndoManagerSupplier
> xSuppUndo( getModel(), uno::UNO_QUERY_THROW
);
616 m_xUndoManager
.set( xSuppUndo
->getUndoManager(), uno::UNO_QUERY_THROW
);
621 uno::Reference
< frame::XFrame
> SAL_CALL ChartController
622 ::getFrame() throw(uno::RuntimeException
)
624 //provides access to owner frame of this controller
625 //return the frame containing this controller
630 uno::Reference
< frame::XModel
> SAL_CALL ChartController
631 ::getModel() throw(uno::RuntimeException
)
633 //provides access to currently attached model
634 //returns the currently attached model
636 //return nothing, if you do not have a model
637 TheModelRef
aModelRef( m_aModel
, m_aModelMutex
);
639 return aModelRef
->getModel();
641 return uno::Reference
< frame::XModel
> ();
644 uno::Any SAL_CALL ChartController
645 ::getViewData() throw(uno::RuntimeException
)
647 //provides access to current view status
648 //set of data that can be used to restore the current view status at later time
649 // by using XController::restoreViewData()
651 SolarMutexGuard aGuard
;
652 if( impl_isDisposedOrSuspended() )
653 return uno::Any(); //behave passive if already disposed or suspended //@todo? or throw an exception??
655 //-- collect current view state
657 //// @todo integrate specialized implementation
662 void SAL_CALL ChartController
663 ::restoreViewData( const uno::Any
& /* Value */ )
664 throw(uno::RuntimeException
)
666 //restores the view status using the data gotten from a previous call to XController::getViewData()
668 SolarMutexGuard aGuard
;
669 if( impl_isDisposedOrSuspended() )
670 return; //behave passive if already disposed or suspended //@todo? or throw an exception??
672 //// @todo integrate specialized implementation
675 sal_Bool SAL_CALL ChartController
676 ::suspend( sal_Bool bSuspend
)
677 throw(uno::RuntimeException
)
679 //is called to prepare the controller for closing the view
680 //bSuspend==true: force the controller to suspend his work
681 //bSuspend==false try to reactivate the controller
682 //returns true if request was accepted and of course successfully finished, false otherwise
684 //we may show dialogs here to ask the user for saving changes ... @todo?
686 SolarMutexGuard aGuard
;
687 if( m_aLifeTimeManager
.impl_isDisposed() )
688 return sal_False
; //behave passive if already disposed, return false because request was not accepted //@todo? correct
690 if(bSuspend
==m_bSuspended
)
692 OSL_FAIL( "new suspend mode equals old suspend mode" );
696 //change suspend mode
699 m_bSuspended
= bSuspend
;
704 m_bSuspended
= bSuspend
;
710 void ChartController::impl_createDrawViewController()
712 SolarMutexGuard aGuard
;
713 if(!m_pDrawViewWrapper
)
715 if( m_pDrawModelWrapper
)
717 m_pDrawViewWrapper
= new DrawViewWrapper(&m_pDrawModelWrapper
->getSdrModel(),m_pChartWindow
,true);
718 m_pDrawViewWrapper
->attachParentReferenceDevice( getModel() );
722 void ChartController::impl_deleteDrawViewController()
724 if( m_pDrawViewWrapper
)
726 SolarMutexGuard aGuard
;
727 if( m_pDrawViewWrapper
->IsTextEdit() )
729 DELETEZ( m_pDrawViewWrapper
);
733 //-----------------------------------------------------------------
734 // XComponent (base of XController)
735 //-----------------------------------------------------------------
737 void SAL_CALL ChartController
738 ::dispose() throw(uno::RuntimeException
)
742 //This object should release all resources and references in the
743 //easiest possible manner
744 //This object must notify all registered listeners using the method
745 //<member>XEventListener::disposing</member>
748 if( !m_aLifeTimeManager
.dispose() )
751 // OSL_ENSURE( m_bSuspended, "dispose was called but controller is not suspended" );
753 this->stopDoubleClickWaiting();
755 //end range highlighting
758 uno::Reference
< view::XSelectionChangeListener
> xSelectionChangeListener
;
759 uno::Reference
< chart2::data::XDataReceiver
> xDataReceiver( getModel(), uno::UNO_QUERY
);
760 if( xDataReceiver
.is() )
761 xSelectionChangeListener
= uno::Reference
< view::XSelectionChangeListener
>( xDataReceiver
->getRangeHighlighter(), uno::UNO_QUERY
);
762 if( xSelectionChangeListener
.is() )
764 uno::Reference
< frame::XController
> xController( this );
765 uno::Reference
< lang::XComponent
> xComp( xController
, uno::UNO_QUERY
);
766 lang::EventObject
aEvent( xComp
);
767 xSelectionChangeListener
->disposing( aEvent
);
771 //--release all resources and references
773 uno::Reference
< util::XModeChangeBroadcaster
> xViewBroadcaster( m_xChartView
, uno::UNO_QUERY
);
774 if( xViewBroadcaster
.is() )
775 xViewBroadcaster
->removeModeChangeListener(this);
777 impl_invalidateAccessible();
778 SolarMutexGuard aSolarGuard
;
779 impl_deleteDrawViewController();
780 m_pDrawModelWrapper
.reset();
782 m_apDropTargetHelper
.reset();
784 //the accessible view is disposed within window destructor of m_pChartWindow
785 m_pChartWindow
->clear();
786 m_pChartWindow
= NULL
;//m_pChartWindow is deleted via UNO due to dispose of m_xViewWindow (trigerred by Framework (Controller pretends to be XWindow also))
787 m_xViewWindow
->dispose();
788 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 SolarMutexGuard aGuard
;
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 SolarMutexGuard aGuard
;
855 if( m_aLifeTimeManager
.impl_isDisposed(false) )
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_FAIL( "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( const 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;
941 m_aDispatchContainer
.setModel( 0 );
942 return bReleaseModel
;
945 //-----------------------------------------------------------------
946 // util::XEventListener (base of XCloseListener)
947 //-----------------------------------------------------------------
948 void SAL_CALL ChartController
949 ::disposing( const lang::EventObject
& rSource
)
950 throw(uno::RuntimeException
)
952 if( !impl_releaseThisModel( rSource
.Source
))
954 if( rSource
.Source
== m_xLayoutManagerEventBroadcaster
)
955 m_xLayoutManagerEventBroadcaster
.set( 0 );
959 void SAL_CALL
ChartController::layoutEvent( const lang::EventObject
& aSource
, ::sal_Int16 eLayoutEvent
, const uno::Any
& /* aInfo */ )
960 throw (uno::RuntimeException
)
962 if( eLayoutEvent
== frame::LayoutManagerEvents::MERGEDMENUBAR
)
964 Reference
< frame::XLayoutManager
> xLM( aSource
.Source
, uno::UNO_QUERY
);
967 xLM
->createElement( C2U("private:resource/statusbar/statusbar"));
968 xLM
->requestElement( C2U("private:resource/statusbar/statusbar"));
974 //-----------------------------------------------------------------
975 // XDispatchProvider (required interface)
976 //-----------------------------------------------------------------
980 bool lcl_isFormatObjectCommand( const rtl::OString
& aCommand
)
982 if( aCommand
.equals("MainTitle")
983 || aCommand
.equals("SubTitle")
984 || aCommand
.equals("XTitle")
985 || aCommand
.equals("YTitle")
986 || aCommand
.equals("ZTitle")
987 || aCommand
.equals("SecondaryXTitle")
988 || aCommand
.equals("SecondaryYTitle")
989 || aCommand
.equals("AllTitles")
990 || aCommand
.equals("DiagramAxisX")
991 || aCommand
.equals("DiagramAxisY")
992 || aCommand
.equals("DiagramAxisZ")
993 || aCommand
.equals("DiagramAxisA")
994 || aCommand
.equals("DiagramAxisB")
995 || aCommand
.equals("DiagramAxisAll")
996 || aCommand
.equals("DiagramGridXMain")
997 || aCommand
.equals("DiagramGridYMain")
998 || aCommand
.equals("DiagramGridZMain")
999 || aCommand
.equals("DiagramGridXHelp")
1000 || aCommand
.equals("DiagramGridYHelp")
1001 || aCommand
.equals("DiagramGridZHelp")
1002 || aCommand
.equals("DiagramGridAll")
1004 || aCommand
.equals("DiagramWall")
1005 || aCommand
.equals("DiagramFloor")
1006 || aCommand
.equals("DiagramArea")
1007 || aCommand
.equals("Legend")
1009 || aCommand
.equals("FormatWall")
1010 || aCommand
.equals("FormatFloor")
1011 || aCommand
.equals("FormatChartArea")
1012 || aCommand
.equals("FormatLegend")
1014 || aCommand
.equals("FormatTitle")
1015 || aCommand
.equals("FormatAxis")
1016 || aCommand
.equals("FormatDataSeries")
1017 || aCommand
.equals("FormatDataPoint")
1018 || aCommand
.equals("FormatDataLabels")
1019 || aCommand
.equals("FormatDataLabel")
1020 || aCommand
.equals("FormatXErrorBars")
1021 || aCommand
.equals("FormatYErrorBars")
1022 || aCommand
.equals("FormatMeanValue")
1023 || aCommand
.equals("FormatTrendline")
1024 || aCommand
.equals("FormatTrendlineEquation")
1025 || aCommand
.equals("FormatStockLoss")
1026 || aCommand
.equals("FormatStockGain")
1027 || aCommand
.equals("FormatMajorGrid")
1028 || aCommand
.equals("FormatMinorGrid")
1035 } // anonymous namespace
1037 uno::Reference
<frame::XDispatch
> SAL_CALL ChartController
1038 ::queryDispatch( const util::URL
& rURL
1039 , const rtl::OUString
& rTargetFrameName
1040 , sal_Int32
/* nSearchFlags */)
1041 throw(uno::RuntimeException
)
1043 if ( !m_aLifeTimeManager
.impl_isDisposed() && getModel().is() )
1045 if( !rTargetFrameName
.isEmpty() && rTargetFrameName
== "_self" )
1046 return m_aDispatchContainer
.getDispatchForURL( rURL
);
1048 return uno::Reference
< frame::XDispatch
> ();
1051 uno::Sequence
<uno::Reference
<frame::XDispatch
> > ChartController
1052 ::queryDispatches( const uno::Sequence
<
1053 frame::DispatchDescriptor
>& xDescripts
)
1054 throw(uno::RuntimeException
)
1056 if ( !m_aLifeTimeManager
.impl_isDisposed() )
1058 return m_aDispatchContainer
.getDispatchesForURLs( xDescripts
);
1060 return uno::Sequence
<uno::Reference
<frame::XDispatch
> > ();
1063 //-----------------------------------------------------------------
1065 //-----------------------------------------------------------------
1067 void SAL_CALL ChartController
1068 ::dispatch( const util::URL
& rURL
1069 , const uno::Sequence
< beans::PropertyValue
>& rArgs
)
1070 throw (uno::RuntimeException
)
1072 //@todo avoid OString
1073 rtl::OString
aCommand( rtl::OUStringToOString( rURL
.Path
, RTL_TEXTENCODING_ASCII_US
) );
1075 if(aCommand
.equals("Paste"))
1076 this->executeDispatch_Paste();
1077 else if(aCommand
.equals("Copy"))
1078 this->executeDispatch_Copy();
1079 else if(aCommand
.equals("Cut"))
1080 this->executeDispatch_Cut();
1081 else if(aCommand
.equals("DataRanges"))
1082 this->executeDispatch_SourceData();
1083 //----------------------------------
1084 else if(aCommand
.equals("Update")) //Update Chart
1086 ChartViewHelper::setViewToDirtyState( getModel() );
1087 SolarMutexGuard aGuard
;
1088 if( m_pChartWindow
)
1089 m_pChartWindow
->Invalidate();
1091 else if(aCommand
.equals("DiagramData"))
1092 this->executeDispatch_EditData();
1094 else if( aCommand
.equals("InsertTitles")
1095 || aCommand
.equals("InsertMenuTitles") )
1096 this->executeDispatch_InsertTitles();
1097 else if( aCommand
.equals("InsertMenuLegend") )
1098 this->executeDispatch_OpenLegendDialog();
1099 else if( aCommand
.equals("InsertLegend") )
1100 this->executeDispatch_InsertLegend();
1101 else if( aCommand
.equals("DeleteLegend") )
1102 this->executeDispatch_DeleteLegend();
1103 else if( aCommand
.equals("InsertMenuDataLabels"))
1104 this->executeDispatch_InsertMenu_DataLabels();
1105 else if( aCommand
.equals("InsertMenuAxes")
1106 || aCommand
.equals("InsertRemoveAxes") )
1107 this->executeDispatch_InsertAxes();
1108 else if( aCommand
.equals("InsertMenuGrids"))
1109 this->executeDispatch_InsertGrid();
1110 else if( aCommand
.equals("InsertMenuTrendlines"))
1111 this->executeDispatch_InsertMenu_Trendlines();
1112 else if( aCommand
.equals("InsertMenuMeanValues"))
1113 this->executeDispatch_InsertMenu_MeanValues();
1114 else if( aCommand
.equals("InsertMenuXErrorBars"))
1115 this->executeDispatch_InsertErrorBars(false);
1116 else if( aCommand
.equals("InsertMenuYErrorBars"))
1117 this->executeDispatch_InsertErrorBars(true);
1118 else if( aCommand
.equals("InsertSymbol"))
1119 this->executeDispatch_InsertSpecialCharacter();
1120 else if( aCommand
.equals("InsertTrendline"))
1121 this->executeDispatch_InsertTrendline();
1122 else if( aCommand
.equals("DeleteTrendline"))
1123 this->executeDispatch_DeleteTrendline();
1124 else if( aCommand
.equals("InsertMeanValue"))
1125 this->executeDispatch_InsertMeanValue();
1126 else if( aCommand
.equals("DeleteMeanValue"))
1127 this->executeDispatch_DeleteMeanValue();
1128 else if( aCommand
.equals("InsertXErrorBars"))
1129 this->executeDispatch_InsertErrorBars(false);
1130 else if( aCommand
.equals("InsertYErrorBars"))
1131 this->executeDispatch_InsertErrorBars(true);
1132 else if( aCommand
.equals("DeleteXErrorBars"))
1133 this->executeDispatch_DeleteErrorBars(false);
1134 else if( aCommand
.equals("DeleteYErrorBars"))
1135 this->executeDispatch_DeleteErrorBars(true);
1136 else if( aCommand
.equals("InsertTrendlineEquation"))
1137 this->executeDispatch_InsertTrendlineEquation();
1138 else if( aCommand
.equals("DeleteTrendlineEquation"))
1139 this->executeDispatch_DeleteTrendlineEquation();
1140 else if( aCommand
.equals("InsertTrendlineEquationAndR2"))
1141 this->executeDispatch_InsertTrendlineEquation( true );
1142 else if( aCommand
.equals("InsertR2Value"))
1143 this->executeDispatch_InsertR2Value();
1144 else if( aCommand
.equals("DeleteR2Value"))
1145 this->executeDispatch_DeleteR2Value();
1146 else if( aCommand
.equals("InsertDataLabels") )
1147 this->executeDispatch_InsertDataLabels();
1148 else if( aCommand
.equals("InsertDataLabel") )
1149 this->executeDispatch_InsertDataLabel();
1150 else if( aCommand
.equals("DeleteDataLabels") )
1151 this->executeDispatch_DeleteDataLabels();
1152 else if( aCommand
.equals("DeleteDataLabel") )
1153 this->executeDispatch_DeleteDataLabel();
1154 else if( aCommand
.equals("ResetAllDataPoints") )
1155 this->executeDispatch_ResetAllDataPoints();
1156 else if( aCommand
.equals("ResetDataPoint") )
1157 this->executeDispatch_ResetDataPoint();
1158 else if( aCommand
.equals("InsertAxis") )
1159 this->executeDispatch_InsertAxis();
1160 else if( aCommand
.equals("InsertMajorGrid") )
1161 this->executeDispatch_InsertMajorGrid();
1162 else if( aCommand
.equals("InsertMinorGrid") )
1163 this->executeDispatch_InsertMinorGrid();
1164 else if( aCommand
.equals("InsertAxisTitle") )
1165 this->executeDispatch_InsertAxisTitle();
1166 else if( aCommand
.equals("DeleteAxis") )
1167 this->executeDispatch_DeleteAxis();
1168 else if( aCommand
.equals("DeleteMajorGrid") )
1169 this->executeDispatch_DeleteMajorGrid();
1170 else if( aCommand
.equals("DeleteMinorGrid") )
1171 this->executeDispatch_DeleteMinorGrid();
1173 else if( aCommand
.equals("FormatSelection") )
1174 this->executeDispatch_ObjectProperties();
1175 else if( aCommand
.equals("TransformDialog"))
1177 if ( isShapeContext() )
1179 this->impl_ShapeControllerDispatch( rURL
, rArgs
);
1183 this->executeDispatch_PositionAndSize();
1186 else if( lcl_isFormatObjectCommand(aCommand
) )
1187 this->executeDispatch_FormatObject(rURL
.Path
);
1189 else if( aCommand
.equals("DiagramType"))
1190 this->executeDispatch_ChartType();
1191 else if( aCommand
.equals("View3D"))
1192 this->executeDispatch_View3D();
1193 else if ( aCommand
.equals( "Forward" ) )
1195 if ( isShapeContext() )
1197 this->impl_ShapeControllerDispatch( rURL
, rArgs
);
1201 this->executeDispatch_MoveSeries( sal_True
);
1204 else if ( aCommand
.equals( "Backward" ) )
1206 if ( isShapeContext() )
1208 this->impl_ShapeControllerDispatch( rURL
, rArgs
);
1212 this->executeDispatch_MoveSeries( sal_False
);
1215 else if( aCommand
.equals("NewArrangement"))
1216 this->executeDispatch_NewArrangement();
1217 else if( aCommand
.equals("ToggleLegend"))
1218 this->executeDispatch_ToggleLegend();
1219 else if( aCommand
.equals("ToggleGridHorizontal"))
1220 this->executeDispatch_ToggleGridHorizontal();
1221 else if( aCommand
.equals("ScaleText"))
1222 this->executeDispatch_ScaleText();
1223 else if( aCommand
.equals("StatusBarVisible"))
1225 // workaround: this should not be necessary.
1226 uno::Reference
< beans::XPropertySet
> xPropSet( m_xFrame
, uno::UNO_QUERY
);
1229 uno::Reference
< ::com::sun::star::frame::XLayoutManager
> xLayoutManager
;
1230 xPropSet
->getPropertyValue( C2U( "LayoutManager" ) ) >>= xLayoutManager
;
1231 if ( xLayoutManager
.is() )
1233 bool bIsVisible( xLayoutManager
->isElementVisible( C2U("private:resource/statusbar/statusbar")));
1236 xLayoutManager
->hideElement( C2U( "private:resource/statusbar/statusbar"));
1237 xLayoutManager
->destroyElement( C2U( "private:resource/statusbar/statusbar"));
1241 xLayoutManager
->createElement( C2U( "private:resource/statusbar/statusbar"));
1242 xLayoutManager
->showElement( C2U( "private:resource/statusbar/statusbar"));
1244 // @todo: update menu state (checkmark next to "Statusbar").
1250 void SAL_CALL ChartController
1251 ::addStatusListener( const uno::Reference
<frame::XStatusListener
>& /* xControl */
1252 , const util::URL
& /* aURL */ )
1253 throw (uno::RuntimeException
)
1258 void SAL_CALL ChartController
1259 ::removeStatusListener( const uno::Reference
<frame::XStatusListener
>& /* xControl */
1260 , const util::URL
& /* aURL */ )
1261 throw (uno::RuntimeException
)
1266 //-----------------------------------------------------------------
1267 // XContextMenuInterception (optional interface)
1268 //-----------------------------------------------------------------
1269 void SAL_CALL ChartController
1270 ::registerContextMenuInterceptor( const uno::Reference
<
1271 ui::XContextMenuInterceptor
> & /* xInterceptor */)
1272 throw(uno::RuntimeException
)
1277 void SAL_CALL ChartController
1278 ::releaseContextMenuInterceptor( const uno::Reference
<
1279 ui::XContextMenuInterceptor
> & /* xInterceptor */)
1280 throw(uno::RuntimeException
)
1285 // ____ XEmbeddedClient ____
1286 // implementation see: ChartController_EditData.cxx
1288 //-----------------------------------------------------------------------------
1289 //-----------------------------------------------------------------------------
1290 //-----------------------------------------------------------------------------
1292 void SAL_CALL
ChartController::executeDispatch_ChartType()
1294 // using assignment for broken gcc 3.3
1295 UndoLiveUpdateGuard aUndoGuard
= UndoLiveUpdateGuard(
1296 String( SchResId( STR_ACTION_EDIT_CHARTTYPE
)), m_xUndoManager
);
1298 SolarMutexGuard aSolarGuard
;
1299 //prepare and open dialog
1300 ChartTypeDialog
aDlg( m_pChartWindow
, getModel(), m_xCC
);
1301 if( aDlg
.Execute() == RET_OK
)
1303 impl_adaptDataSeriesAutoResize();
1304 aUndoGuard
.commit();
1308 void SAL_CALL
ChartController::executeDispatch_SourceData()
1310 //-------------------------------------------------------------
1311 //convert properties to ItemSet
1312 uno::Reference
< XChartDocument
> xChartDoc( getModel(), uno::UNO_QUERY
);
1313 OSL_ENSURE( xChartDoc
.is(), "Invalid XChartDocument" );
1314 if( !xChartDoc
.is())
1317 // using assignment for broken gcc 3.3
1318 UndoLiveUpdateGuard aUndoGuard
= UndoLiveUpdateGuard(
1319 String( SchResId( STR_ACTION_EDIT_DATA_RANGES
)), m_xUndoManager
);
1322 SolarMutexGuard aSolarGuard
;
1323 ::chart::DataSourceDialog
aDlg( m_pChartWindow
, xChartDoc
, m_xCC
);
1324 if( aDlg
.Execute() == RET_OK
)
1326 impl_adaptDataSeriesAutoResize();
1327 aUndoGuard
.commit();
1332 void SAL_CALL
ChartController::executeDispatch_MoveSeries( sal_Bool bForward
)
1334 ControllerLockGuard
aCLGuard( getModel() );
1336 //get selected series
1337 ::rtl::OUString
aObjectCID(m_aSelection
.getSelectedCID());
1338 uno::Reference
< XDataSeries
> xGivenDataSeries( ObjectIdentifier::getDataSeriesForCID( //yyy todo also legendentries and labels?
1339 aObjectCID
, getModel() ) );
1341 UndoGuardWithSelection
aUndoGuard(
1342 ActionDescriptionProvider::createDescription(
1343 (bForward
? ActionDescriptionProvider::MOVE_TOTOP
: ActionDescriptionProvider::MOVE_TOBOTTOM
),
1344 String( SchResId( STR_OBJECT_DATASERIES
))),
1347 bool bChanged
= DiagramHelper::moveSeries( ChartModelHelper::findDiagram( getModel() ), xGivenDataSeries
, bForward
);
1350 m_aSelection
.setSelection( ObjectIdentifier::getMovedSeriesCID( aObjectCID
, bForward
) );
1351 aUndoGuard
.commit();
1355 // ____ XMultiServiceFactory ____
1356 uno::Reference
< uno::XInterface
> SAL_CALL
1357 ChartController::createInstance( const ::rtl::OUString
& aServiceSpecifier
)
1358 throw (uno::Exception
,
1359 uno::RuntimeException
)
1361 uno::Reference
< uno::XInterface
> xResult
;
1363 if( aServiceSpecifier
.equals( CHART_ACCESSIBLE_TEXT_SERVICE_NAME
))
1364 xResult
.set( impl_createAccessibleTextContext());
1368 uno::Reference
< uno::XInterface
> SAL_CALL
1369 ChartController::createInstanceWithArguments( const ::rtl::OUString
& ServiceSpecifier
,
1370 const uno::Sequence
< uno::Any
>& /* Arguments */ )
1371 throw (uno::Exception
,
1372 uno::RuntimeException
)
1375 return createInstance( ServiceSpecifier
);
1378 uno::Sequence
< ::rtl::OUString
> SAL_CALL
1379 ChartController::getAvailableServiceNames()
1380 throw (uno::RuntimeException
)
1382 uno::Sequence
< ::rtl::OUString
> aServiceNames(1);
1383 aServiceNames
[0] = CHART_ACCESSIBLE_TEXT_SERVICE_NAME
;
1384 return aServiceNames
;
1387 // ____ XModifyListener ____
1388 void SAL_CALL
ChartController::modified( const lang::EventObject
& /* aEvent */ )
1389 throw (uno::RuntimeException
)
1391 // the source can also be a subobject of the ChartModel
1392 // @todo: change the source in ChartModel to always be the model itself ?
1393 //todo? update menu states ?
1396 //-----------------------------------------------------------------------------
1398 IMPL_LINK( ChartController
, NotifyUndoActionHdl
, SdrUndoAction
*, pUndoAction
)
1400 ENSURE_OR_RETURN( pUndoAction
, "invalid Undo action", 1L );
1402 ::rtl::OUString aObjectCID
= m_aSelection
.getSelectedCID();
1403 if ( aObjectCID
.isEmpty() )
1407 const Reference
< document::XUndoManagerSupplier
> xSuppUndo( getModel(), uno::UNO_QUERY_THROW
);
1408 const Reference
< document::XUndoManager
> xUndoManager( xSuppUndo
->getUndoManager(), uno::UNO_QUERY_THROW
);
1409 const Reference
< document::XUndoAction
> xAction( new impl::ShapeUndoElement( *pUndoAction
) );
1410 xUndoManager
->addUndoAction( xAction
);
1412 catch( const uno::Exception
& )
1414 DBG_UNHANDLED_EXCEPTION();
1420 DrawModelWrapper
* ChartController::GetDrawModelWrapper()
1422 if( !m_pDrawModelWrapper
.get() )
1424 ExplicitValueProvider
* pProvider
= ExplicitValueProvider::getExplicitValueProvider( m_xChartView
);
1426 m_pDrawModelWrapper
= pProvider
->getDrawModelWrapper();
1427 if ( m_pDrawModelWrapper
.get() )
1429 m_pDrawModelWrapper
->getSdrModel().SetNotifyUndoActionHdl( LINK( this, ChartController
, NotifyUndoActionHdl
) );
1432 return m_pDrawModelWrapper
.get();
1435 DrawViewWrapper
* ChartController::GetDrawViewWrapper()
1437 if ( !m_pDrawViewWrapper
)
1439 impl_createDrawViewController();
1441 return m_pDrawViewWrapper
;
1444 uno::Reference
< XAccessible
> ChartController::CreateAccessible()
1446 uno::Reference
< XAccessible
> xResult
= new AccessibleChartView( m_xCC
, GetDrawViewWrapper() );
1447 impl_initializeAccessible( uno::Reference
< lang::XInitialization
>( xResult
, uno::UNO_QUERY
) );
1451 void ChartController::impl_invalidateAccessible()
1453 SolarMutexGuard aGuard
;
1454 if( m_pChartWindow
)
1456 Reference
< lang::XInitialization
> xInit( m_pChartWindow
->GetAccessible(false), uno::UNO_QUERY
);
1459 uno::Sequence
< uno::Any
> aArguments(3);//empty arguments -> invalid accessible
1460 xInit
->initialize(aArguments
);
1464 void ChartController::impl_initializeAccessible()
1466 SolarMutexGuard aGuard
;
1467 if( m_pChartWindow
)
1468 this->impl_initializeAccessible( Reference
< lang::XInitialization
>( m_pChartWindow
->GetAccessible(false), uno::UNO_QUERY
) );
1470 void ChartController::impl_initializeAccessible( const uno::Reference
< lang::XInitialization
>& xInit
)
1474 uno::Sequence
< uno::Any
> aArguments(5);
1475 uno::Reference
<view::XSelectionSupplier
> xSelectionSupplier(this);
1476 aArguments
[0]=uno::makeAny(xSelectionSupplier
);
1477 uno::Reference
<frame::XModel
> xModel(getModel());
1478 aArguments
[1]=uno::makeAny(xModel
);
1479 aArguments
[2]=uno::makeAny(m_xChartView
);
1480 uno::Reference
< XAccessible
> xParent
;
1482 SolarMutexGuard aGuard
;
1483 if( m_pChartWindow
)
1485 Window
* pParentWin( m_pChartWindow
->GetAccessibleParentWindow());
1487 xParent
.set( pParentWin
->GetAccessible());
1490 aArguments
[3]=uno::makeAny(xParent
);
1491 aArguments
[4]=uno::makeAny(m_xViewWindow
);
1493 xInit
->initialize(aArguments
);
1497 ::std::set
< ::rtl::OUString
> ChartController::impl_getAvailableCommands()
1499 return ::comphelper::MakeSet
< ::rtl::OUString
>
1500 // commands for container forward
1501 ( "AddDirect" ) ( "NewDoc" ) ( "Open" )
1502 ( "Save" ) ( "SaveAs" ) ( "SendMail" )
1503 ( "EditDoc" ) ( "ExportDirectToPDF" ) ( "PrintDefault" )
1506 ( "Cut" ) ( "Copy" ) ( "Paste" )
1507 ( "DataRanges" ) ( "DiagramData" )
1509 ( "InsertMenuTitles" ) ( "InsertTitles" )
1510 ( "InsertMenuLegend" ) ( "InsertLegend" ) ( "DeleteLegend" )
1511 ( "InsertMenuDataLabels" )
1512 ( "InsertMenuAxes" ) ( "InsertRemoveAxes" ) ( "InsertMenuGrids" )
1514 ( "InsertTrendlineEquation" ) ( "InsertTrendlineEquationAndR2" )
1515 ( "InsertR2Value" ) ( "DeleteR2Value" )
1516 ( "InsertMenuTrendlines" ) ( "InsertTrendline" )
1517 ( "InsertMenuMeanValues" ) ( "InsertMeanValue" )
1518 ( "InsertMenuXErrorBars" ) ( "InsertXErrorBars" )
1519 ( "InsertMenuYErrorBars" ) ( "InsertYErrorBars" )
1520 ( "InsertDataLabels" ) ( "InsertDataLabel" )
1521 ( "DeleteTrendline" ) ( "DeleteMeanValue" ) ( "DeleteTrendlineEquation" )
1522 ( "DeleteXErrorBars" ) ( "DeleteYErrorBars" )
1523 ( "DeleteDataLabels" ) ( "DeleteDataLabel" )
1525 ( "FormatSelection" ) ( "TransformDialog" )
1526 ( "DiagramType" ) ( "View3D" )
1527 ( "Forward" ) ( "Backward" )
1528 ( "MainTitle" ) ( "SubTitle" )
1529 ( "XTitle" ) ( "YTitle" ) ( "ZTitle" )
1530 ( "SecondaryXTitle" ) ( "SecondaryYTitle" )
1531 ( "AllTitles" ) ( "Legend" )
1532 ( "DiagramAxisX" ) ( "DiagramAxisY" ) ( "DiagramAxisZ" )
1533 ( "DiagramAxisA" ) ( "DiagramAxisB" ) ( "DiagramAxisAll" )
1534 ( "DiagramGridXMain" ) ( "DiagramGridYMain" ) ( "DiagramGridZMain" )
1535 ( "DiagramGridXHelp" ) ( "DiagramGridYHelp" ) ( "DiagramGridZHelp" )
1536 ( "DiagramGridAll" )
1537 ( "DiagramWall" ) ( "DiagramFloor" ) ( "DiagramArea" )
1539 //context menu - format objects entries
1540 ( "FormatWall" ) ( "FormatFloor" ) ( "FormatChartArea" )
1543 ( "FormatAxis" ) ( "FormatTitle" )
1544 ( "FormatDataSeries" ) ( "FormatDataPoint" )
1545 ( "ResetAllDataPoints" ) ( "ResetDataPoint" )
1546 ( "FormatDataLabels" ) ( "FormatDataLabel" )
1547 ( "FormatMeanValue" ) ( "FormatTrendline" ) ( "FormatTrendlineEquation" )
1548 ( "FormatXErrorBars" ) ( "FormatYErrorBars" )
1549 ( "FormatStockLoss" ) ( "FormatStockGain" )
1551 ( "FormatMajorGrid" ) ( "InsertMajorGrid" ) ( "DeleteMajorGrid" )
1552 ( "FormatMinorGrid" ) ( "InsertMinorGrid" ) ( "DeleteMinorGrid" )
1553 ( "InsertAxis" ) ( "DeleteAxis" ) ( "InsertAxisTitle" )
1556 ( "ToggleGridHorizontal" )( "ToggleLegend" ) ( "ScaleText" )
1557 ( "NewArrangement" ) ( "Update" )
1558 ( "DefaultColors" ) ( "BarWidth" ) ( "NumberOfLines" )
1560 ( "StatusBarVisible" )
1561 ( "ChartElementSelector" )
1565 //.............................................................................
1567 //.............................................................................
1569 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */