diff options
author | Vladimir Glazounov <vg@openoffice.org> | 2007-05-22 17:02:54 +0000 |
---|---|---|
committer | Vladimir Glazounov <vg@openoffice.org> | 2007-05-22 17:02:54 +0000 |
commit | c6b95527d2e00ed3a4cf3bad3a328ca5b29a588a (patch) | |
tree | ca81a85f41b92ade738ee1fdbec9b65979d549c0 /chart2/source/controller/main/ChartController.cxx | |
parent | 9b95322d5ea09e1f533163df3f6bd502d9bb085f (diff) |
INTEGRATION: CWS chart2mst3 (1.15.4); FILE MERGED
2007/02/07 13:07:41 iha 1.15.4.109: RESYNC: (1.19-1.20); FILE MERGED
2007/02/02 11:29:51 iha 1.15.4.108: imlemented cut
2007/02/01 16:53:49 iha 1.15.4.107: remove superfluous code from old context menu
2007/01/22 17:32:29 iha 1.15.4.106: remove slot .uno:AutoFormat
2007/01/16 16:24:46 iha 1.15.4.105: #i73426# wrong help context bvecause of wrong window hirarchy
2006/11/26 11:38:59 bm 1.15.4.104: includes for solar mutex missing
2006/11/22 17:24:09 iha 1.15.4.103: RESYNC: (1.18-1.19); FILE MERGED
2006/11/07 16:55:27 bm 1.15.4.102: forward container commands to container dispatcher
2006/10/27 14:59:20 iha 1.15.4.101: name consolidation
2006/10/24 14:27:44 bm 1.15.4.100: pass chart window as parent to DataSourceDialog instead of NULL
2006/10/24 11:54:20 bm 1.15.4.99: remove commands that are handled by server application (save, save as, etc.)
2006/10/20 21:12:21 iha 1.15.4.98: implement selection of additional shapes
2006/10/18 17:07:18 bm 1.15.4.97: RESYNC: (1.17-1.18); FILE MERGED
2006/10/16 15:19:42 bm 1.15.4.96: #i70287# implement toggle grid horizontal command
2006/10/11 09:19:53 bm 1.15.4.95: #i20287# implement toggle legend command, remove unused toolbar commands
2006/10/06 09:11:06 bm 1.15.4.94: #i64500# clipboard for chart objects
2006/09/28 16:46:28 bm 1.15.4.93: #i64500# clipboard paste of metafiles, bitmaps and text
2006/08/22 17:31:53 bm 1.15.4.92: #i68861# implement the status bar
2006/07/11 13:20:37 bm 1.15.4.91: reset drop target helper in dispose()
2006/06/29 13:54:40 bm 1.15.4.90: dropping dragged cell-ranges from calc here. Missing: determine if the originating document is the container
2006/05/29 17:56:16 iha 1.15.4.89: replaced STR_OBJECT_SOURCE_DATA by STR_OBJECT_DATA_RANGE
2006/03/23 09:57:10 bm 1.15.4.88: support for paragraphs for accessibility titles
2006/03/19 15:33:20 iha 1.15.4.87: correct selection handling of datapoints and series
2006/03/18 20:53:00 iha 1.15.4.86: correct selection handling for rotating diagram
2006/03/15 13:57:08 bm 1.15.4.85: documentation of dispatch stuff. Also moved the command list of the controller to the controller itself
2006/03/12 01:21:17 iha 1.15.4.84: changed communication between model, view and controller; implemented old AddIn Interface; changed owneship and lifetime of view
2006/02/20 14:36:48 iha 1.15.4.83: move SchItemPool from controller to view lib -> ChartItemPool
2006/02/20 09:17:36 bm 1.15.4.82: impl_initializeAccessible: XInitialization needs two more parameters
2006/01/24 10:49:42 bm 1.15.4.81: call impl_adaptDataSeriesAutoResize after command execution of commands which may add new data series
2006/01/20 11:39:28 iha 1.15.4.80: some cleanup
2006/01/17 17:16:06 bm 1.15.4.79: clear selection in dispose (to remove range highlighting)
2006/01/13 13:43:34 bm 1.15.4.78: +executeDispatch_NewArrangement(), executeDispatch_ScaleText
2005/12/21 21:29:08 iha 1.15.4.77: remove identifiers from model objects and create an index based CID protocol instead for selection purposes
2005/11/28 15:14:00 bm 1.15.4.76: assertion about CloseVetoException only if OSL_DEBUG_LEVEL > 2
2005/11/28 14:39:29 iha 1.15.4.75: UndoLiveUpdateGuard for charttype dlg and data range dlg
2005/11/28 14:20:05 iha 1.15.4.74: menu changes
2005/11/25 17:42:33 bm 1.15.4.73: command enabling according to model state
2005/11/24 15:07:48 bm 1.15.4.72: allow removing listeners in suspend mode
2005/11/22 10:53:19 bm 1.15.4.71: use correct undo strings
2005/11/21 16:07:45 bm 1.15.4.70: use dispatch command container
2005/11/16 10:57:04 iha 1.15.4.69: use UndoLiveUpdateGuard for Wizard
2005/11/15 20:49:32 iha 1.15.4.68: use UndoGuard
2005/11/15 15:30:25 bm 1.15.4.67: garbage collection, disposing, reference release issues
2005/11/15 10:41:32 iha 1.15.4.66: don't remove me as listener in disposing
2005/11/14 16:50:26 iha 1.15.4.65: remove direct view update call from wizard slot as automatic updates are now available
2005/11/14 14:54:41 iha 1.15.4.64: guard Charttype Dialog against view updates and remove direct view update call
2005/11/11 14:51:15 bm 1.15.4.63: dispose: remove as modify listener from model
2005/11/11 14:43:30 iha 1.15.4.62: guard DataRange Dialog against view updates and remove direct view update call
2005/11/07 20:59:03 iha 1.15.4.61: implement changing series order
2005/11/02 13:49:19 bm 1.15.4.60: scene properties changed from SceneDescriptor property to the D3D properties offered by SceneProperties.hxx (this way XML im-/export works with the xmloff helper)
2005/10/18 14:51:35 bm 1.15.4.59: implement XModifyListener in order to listen to model changes (use define TEST_ENABLE_MODIFY_LISTENER to actually add and remove as listener at the model to get view updates)
2005/10/11 12:44:07 bm 1.15.4.58: using UndoManager for undo/redo
2005/10/07 11:33:19 bm 1.15.4.57: RESYNC: (1.16-1.17); FILE MERGED
2005/09/07 16:02:21 iha 1.15.4.56: added missing include
2005/09/02 14:29:11 iha 1.15.4.55: delete window with solar mutex
2005/08/30 14:46:40 bm 1.15.4.54: attach parent reference-device after creating draw model- and view wrappers
2005/08/29 14:49:37 iha 1.15.4.53: unmark before removing shapes
2005/08/26 13:04:05 bm 1.15.4.52: lock solar mutex when deleting svx objects (DTOR calls)
2005/08/26 10:00:07 bm 1.15.4.51: some more solar mutex locks
2005/08/25 12:35:06 bm 1.15.4.50: lock solar mutex when creating CreationWizard and ChartType dialog
2005/08/22 15:37:39 iha 1.15.4.49: don't create accessibility view for update
2005/08/04 11:52:11 bm 1.15.4.48: lock solar mutex when starting data source dialog
2005/07/27 12:33:12 bm 1.15.4.47: catch exceptions in dispose()
2005/07/13 15:20:07 iha 1.15.4.46: update draw model tables before use in view and dialogs
2005/07/08 14:56:22 iha 1.15.4.45: create and notify an accessible view
2005/07/08 12:59:02 iha 1.15.4.44: disconnect controller from model when disposed
2005/07/08 12:56:35 iha 1.15.4.43: provide and keep view as service only
2005/07/07 08:35:51 iha 1.15.4.42: implement interface XSelectionSupplier
2005/07/07 08:24:44 iha 1.15.4.41: reselect objects after view rebuild
2005/07/05 15:43:29 iha 1.15.4.40: redefine diagram size
2005/06/09 15:51:28 iha 1.15.4.39: support positions and sizes via view for old api wrapper
2005/06/07 15:50:33 iha 1.15.4.38: use numberformatter from model
2005/06/06 11:42:22 cd 1.15.4.37: Use createElement/requestElement calls to create elements always, even if module frame is not visible
2005/06/03 14:40:51 iha 1.15.4.36: construct chartview with drawmodelwrapper, shared_ptr for drawmodelwrapper, no background for chart window
2005/06/01 16:22:53 iha 1.15.4.35: remove interface xpropertyset
2005/05/31 18:57:39 iha 1.15.4.34: create old api without controller
2005/04/27 11:33:59 bm 1.15.4.33: use requestElement rather than createElement for UI ressources, and lock the layoutmanager
2005/04/04 11:39:47 bm 1.15.4.32: AcceleratorExecute helper class for handling accelerator keys
2005/04/04 11:20:09 bm 1.15.4.31: create toolbars / new slot DataRanges
2005/04/01 16:25:38 bm 1.15.4.30: shared data for different chart models
2005/03/31 12:55:16 bm 1.15.4.29: first redo implementation
2005/03/30 16:31:04 bm 1.15.4.28: make model cloneable (+first undo implementation)
2005/03/18 15:48:07 bm 1.15.4.27: XLayoutManager -> drafts namespace removed
2004/09/27 14:33:49 iha 1.15.4.26: save - old api - provide access to ViewElementListProvider, reduce direct access to draw model
2004/09/15 15:44:55 iha 1.15.4.25: implement api redesign
2004/09/03 17:08:14 iha 1.15.4.24: enable save
2004/08/26 15:54:36 iha 1.15.4.23: View independent loading - different setting of page size
2004/08/24 13:51:28 iha 1.15.4.22: View independent loading - store page size separat from window (which does not exist in some cases)
2004/08/04 20:15:17 bm 1.15.4.21: RESYNC: (1.15-1.16); FILE MERGED
2004/06/30 08:09:21 iha 1.15.4.20: #i30866# charttype dialog without roadmap control
2004/06/17 10:03:29 bm 1.15.4.19: data source dialog is a tab dialog now using
the same tabpages as the wizard
2004/06/04 08:05:04 bm 1.15.4.18: +GetDrawModelUNO
2004/06/01 19:03:50 iha 1.15.4.17: new 3D view/effects dialog
2004/05/24 17:47:30 bm 1.15.4.16: data source dialog is deprecated -> is a tabpage now
2004/05/17 17:33:54 iha 1.15.4.15: provide object naming; resource cleanup
2004/04/27 13:31:03 bm 1.15.4.14: DataSourceDialog needs a context to create new data series
2004/04/26 17:33:26 iha 1.15.4.13: #i27367# exchanged own controller mutex against solar mutex because of deadlocks during old api access
2004/04/26 11:15:29 iha 1.15.4.12: #i27367# offer access to created shapes for old api
2004/04/21 16:56:46 iha 1.15.4.11: #i20344# replace old type dialog with new type page
2004/04/21 11:35:17 bm 1.15.4.10: locked SolarMutexes added
2004/04/08 15:20:31 iha 1.15.4.9: added slot SelectSourceRanges
2004/04/08 12:29:51 iha 1.15.4.8: #i20344# offer update slot for view update after wizard has closed
2004/04/07 21:52:47 iha 1.15.4.7: #i20344# added method executeDispatch_CreationWizard
2004/03/24 10:33:51 bm 1.15.4.6: switch to internal calc again in "SaveAll" (Test-method)
2004/03/19 14:32:50 bm 1.15.4.5: XDataSource now contains XLabeledDataSources
2004/03/05 16:44:47 bm 1.15.4.4: lcl_isFormatObjectCommand: return false in else-path (return was missing)
2004/03/05 15:01:43 iha 1.15.4.3: differetn menu creation + changed from slot url scheme to uno url scheme due to menubar framework changes
2004/02/18 17:07:43 iha 1.15.4.2: handle lifetime of the ChartCindow correct
2004/02/13 16:51:19 bm 1.15.4.1: join from changes on branch bm_post_chart01
Diffstat (limited to 'chart2/source/controller/main/ChartController.cxx')
-rw-r--r-- | chart2/source/controller/main/ChartController.cxx | 1047 |
1 files changed, 665 insertions, 382 deletions
diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx index 05b0ab80e736..8b2eb6dcf090 100644 --- a/chart2/source/controller/main/ChartController.cxx +++ b/chart2/source/controller/main/ChartController.cxx @@ -4,9 +4,9 @@ * * $RCSfile: ChartController.cxx,v $ * - * $Revision: 1.20 $ + * $Revision: 1.21 $ * - * last change: $Author: kz $ $Date: 2006-12-12 16:46:01 $ + * last change: $Author: vg $ $Date: 2007-05-22 18:02:54 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -37,43 +37,54 @@ #include "precompiled_chart2.hxx" #include "ChartController.hxx" #include "servicenames.hxx" -#include "SchItemPool.hxx" - -#include "InlineContainer.hxx" -#include "Chart.hrc" #include "ResId.hxx" -#include "SchSlotIds.hxx" +#include "dlg_DataSource.hxx" +#include "ChartModelHelper.hxx" +#include "ControllerCommandDispatch.hxx" +#include "Strings.hrc" +#include "chartview/ExplicitValueProvider.hxx" +#include "ChartViewHelper.hxx" -#include "chartview/ChartView.hxx" #include "ChartWindow.hxx" -#include "DrawModelWrapper.hxx" +#include "chartview/DrawModelWrapper.hxx" #include "DrawViewWrapper.hxx" -#include "DataSeriesTreeHelper.hxx" +#include "ObjectIdentifier.hxx" #include "DiagramHelper.hxx" +#include "ControllerLockGuard.hxx" +#include "UndoGuard.hxx" +#include "ChartDropTargetHelper.hxx" #include "macros.hxx" - -#include "chartview/NumberFormatterWrapper.hxx" - +#include "dlg_CreationWizard.hxx" #include "dlg_ChartType.hxx" +//#include "svx/ActionDescriptionProvider.hxx" -//for SID_CHARMAP: -#ifndef _SVX_SVXIDS_HRC -#include <svx/svxids.hrc> -#endif +#include <comphelper/InlineContainer.hxx> +#ifndef _COM_SUN_STAR_AWT_POSSIZE_HPP_ +#include <com/sun/star/awt/PosSize.hpp> +#endif #ifndef _COM_SUN_STAR_CHART2_XCHARTDOCUMENT_HPP_ #include <com/sun/star/chart2/XChartDocument.hpp> #endif -#ifndef _COM_SUN_STAR_CHART2_XSTACKABLESCALEGROUP_HPP_ -#include <com/sun/star/chart2/XStackableScaleGroup.hpp> -#endif -#ifndef _COM_SUN_STAR_CHART2_XCHARTTYPETEMPLATE_HPP_ -#include <com/sun/star/chart2/XChartTypeTemplate.hpp> -#endif #ifndef _COM_SUN_STAR_FRAME_XLOADABLE_HPP_ #include <com/sun/star/frame/XLoadable.hpp> #endif +#ifndef _COM_SUN_STAR_UTIL_XCLONEABLE_HPP_ +#include <com/sun/star/util/XCloneable.hpp> +#endif +#ifndef _COM_SUN_STAR_EMBED_XEMBEDDEDCLIENT_HPP_ +#include <com/sun/star/embed/XEmbeddedClient.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XMODECHANGEBROADCASTER_HPP_ +#include <com/sun/star/util/XModeChangeBroadcaster.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XMODIFYBROADCASTER_HPP_ +#include <com/sun/star/util/XModifyBroadcaster.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_LAYOUTMANAGEREVENTS_HPP_ +#include <com/sun/star/frame/LayoutManagerEvents.hpp> +#endif //------- // header for define RET_OK @@ -89,20 +100,39 @@ #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ #include <toolkit/helper/vclunohelper.hxx> #endif +#ifndef _SV_SVAPP_HXX +#include <vcl/svapp.hxx> +#endif #ifndef _VOS_MUTEX_HXX_ #include <vos/mutex.hxx> #endif //------- -#ifndef _COMPHELPER_PROCESSFACTORY_HXX_ -#include <comphelper/processfactory.hxx> +#ifndef _COM_SUN_STAR_FRAME_XLAYOUTMANAGER_HPP_ +#include <com/sun/star/frame/XLayoutManager.hpp> #endif -#ifndef _COM_SUN_STAR_UTIL_XURLTRANSFORMER_HPP_ -#include <com/sun/star/util/XURLTransformer.hpp> +#ifndef _COM_SUN_STAR_UI_DIALOGS_XEXECUTABLEDIALOG_HPP_ +#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> #endif +// this is needed to properly destroy the auto_ptr to the AcceleratorExecute +// object in the DTOR +#ifndef INCLUDED_SVTOOLS_ACCELERATOREXECUTE_HXX +#include <svtools/acceleratorexecute.hxx> +#endif + +#ifndef _SVX_ACTIONDESCRIPTIONPROVIDER_HXX +#include <svx/ActionDescriptionProvider.hxx> +#endif + +// enable the following define to let the controller listen to model changes and +// react on this by rebuilding the view +#define TEST_ENABLE_MODIFY_LISTENER + +/* #ifndef _SV_SVAPP_HXX #include <vcl/svapp.hxx> #endif +*/ //............................................................................. namespace chart @@ -111,6 +141,9 @@ namespace chart using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; //----------------------------------------------------------------- // ChartController Constructor and Destructor @@ -125,26 +158,23 @@ ChartController::ChartController(uno::Reference<uno::XComponentContext> const & , m_aModelMutex() , m_aModel( NULL, m_aModelMutex ) , m_pChartWindow( NULL ) - , m_xViewWindow( NULL ) - , m_pChartView( NULL ) - , m_pDrawModelWrapper( NULL ) + , m_xViewWindow() + , m_xChartView() + , m_pDrawModelWrapper() , m_pDrawViewWrapper(NULL) - , m_bViewDirty( false ) - , m_pNumberFormatterWrapper(NULL) + , m_eDragMode(SDRDRAG_MOVE) + , m_bWaitingForDoubleClick(false) + , m_bWaitingForMouseUp(false) + , m_bConnectingToView(false) + , m_aDispatchContainer( m_xCC ) { - - //@todo - m_pNumberFormatterWrapper = new NumberFormatterWrapper(); + m_aDispatchContainer.setUndoManager( & m_aUndoManager ); + m_aDoubleClickTimer.SetTimeoutHdl( LINK( this, ChartController, DoubleClickWaitingHdl ) ); } ChartController::~ChartController() { - impl_deleteView(); - //m_pChartWindow is deleted via UNO by Window hierarchy or Framework - DELETEZ( m_pNumberFormatterWrapper ); - DELETEZ( m_pDrawViewWrapper ); - DELETEZ( m_pDrawModelWrapper ); - //@todo ? + stopDoubleClickWaiting(); } //----------------------------------------------------------------- @@ -205,7 +235,7 @@ void ChartController::TheModel::addListener( ChartController* pController ) { //we need to add as dispose event listener m_xModel->addEventListener( - static_cast<lang::XEventListener*>(pController) ); + static_cast<util::XCloseListener*>(pController) ); } } @@ -218,7 +248,7 @@ void ChartController::TheModel::removeListener( ChartController* pController ) else if( m_xModel.is() ) m_xModel->removeEventListener( - static_cast<lang::XEventListener*>(pController) ); + static_cast<util::XCloseListener*>(pController) ); } void ChartController::TheModel::tryTermination() @@ -246,8 +276,10 @@ void ChartController::TheModel::tryTermination() //since we have indicated to give up the ownership with paramter true in close call //the one who has thrown the CloseVetoException is the new owner +#if OSL_DEBUG_LEVEL > 2 OSL_ENSURE( !m_bOwnership, "INFO: a well known owner has catched a CloseVetoException after calling close(true)" ); +#endif m_bOwnership = false; m_bOwnershipIsWellKnown = sal_True; @@ -328,7 +360,7 @@ sal_Bool ChartController::TheModelRef::is() const //----------------------------------------------------------------- sal_Bool ChartController -::impl_isDisposedOrSuspended() +::impl_isDisposedOrSuspended() const { if( m_aLifeTimeManager.impl_isDisposed() ) return sal_True; @@ -365,7 +397,7 @@ APPHELPER_XSERVICEINFO_IMPL(ChartController,CHART_CONTROLLER_SERVICE_IMPLEMENTAT ::attachFrame( const uno::Reference<frame::XFrame>& xFrame ) throw(uno::RuntimeException) { - osl::Guard< osl::Mutex > aGuard( m_aControllerMutex ); + ::vos::OGuard aGuard( Application::GetSolarMutex()); if( impl_isDisposedOrSuspended() ) //@todo? allow attaching the frame while suspended? return; //behave passive if already disposed or suspended @@ -407,118 +439,130 @@ APPHELPER_XSERVICEINFO_IMPL(ChartController,CHART_CONTROLLER_SERVICE_IMPLEMENTAT if(m_pChartWindow) { //@todo delete ... + m_pChartWindow->clear(); + m_apDropTargetHelper.reset(); } { + awt::Size aPageSize( ChartModelHelper::getPageSize(m_aModel->getModel()) ); + // calls to VCL ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); m_pChartWindow = new ChartWindow(this,pParent,pParent?pParent->GetStyle():0); + m_pChartWindow->SetBackground();//no Background m_xViewWindow = uno::Reference< awt::XWindow >( m_pChartWindow->GetComponentInterface(), uno::UNO_QUERY ); m_pChartWindow->Show(); - } + m_apDropTargetHelper.reset( + new ChartDropTargetHelper( m_pChartWindow->GetDropTarget(), + uno::Reference< chart2::XChartDocument >( m_aModel->getModel(), uno::UNO_QUERY ))); - impl_tryInitializeView(); - - {//create the menu - util::URL aURL( SchResId(RID_MENU).getURL() ); + impl_createDrawViewController(); + } - uno::Reference< lang::XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory(); - uno::Reference< util::XURLTransformer > xTrans( - xMgr->createInstance( ::rtl::OUString::createFromAscii( - "com.sun.star.util.URLTransformer") ), uno::UNO_QUERY ); - if( xTrans.is() ) + //create the menu + { + uno::Reference< beans::XPropertySet > xPropSet( xFrame, uno::UNO_QUERY ); + if( xPropSet.is() ) { - // Datei laden - xTrans->parseStrict( aURL ); - - uno::Reference< frame::XDispatchProvider > xProv( xFrame, uno::UNO_QUERY ); - if ( xProv.is() ) + try { - uno::Reference< frame::XDispatch > aDisp = - xProv->queryDispatch( aURL, - ::rtl::OUString::createFromAscii("_menubar"), 12 ); - if ( aDisp.is() ) - aDisp->dispatch( aURL, uno::Sequence<beans::PropertyValue>() ); + uno::Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager; + xPropSet->getPropertyValue( C2U( "LayoutManager" ) ) >>= xLayoutManager; + if ( xLayoutManager.is() ) + { + xLayoutManager->lock(); + // @todo: All create calls here should not be necessary as + // request should include this. Remove when fixed version is + // in master + xLayoutManager->requestElement( C2U( "private:resource/menubar/menubar" ) ); + xLayoutManager->createElement( C2U( "private:resource/toolbar/standardbar" ) ); + xLayoutManager->requestElement( C2U( "private:resource/toolbar/standardbar" ) ); + xLayoutManager->createElement( C2U( "private:resource/toolbar/toolbar" ) ); + xLayoutManager->requestElement( C2U( "private:resource/toolbar/toolbar" ) ); + xLayoutManager->createElement( C2U( "private:resource/statusbar/statusbar" ) ); + xLayoutManager->requestElement( C2U( "private:resource/statusbar/statusbar" ) ); + xLayoutManager->unlock(); + + // add as listener to get notified when + m_xLayoutManagerEventBroadcaster.set( xLayoutManager, uno::UNO_QUERY ); + if( m_xLayoutManagerEventBroadcaster.is()) + m_xLayoutManagerEventBroadcaster->addLayoutManagerEventListener( this ); + } + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); } } } } -void SAL_CALL ChartController -::impl_rebuildView() - throw(uno::RuntimeException) +//XModeChangeListener +void SAL_CALL ChartController::modeChanged( const util::ModeChangeEvent& rEvent ) + throw ( uno::RuntimeException ) { - m_bViewDirty = false; - impl_tryInitializeView(); - if( m_aSelectedObjectCID.getLength() ) + //adjust controller to view status changes + + if( rEvent.NewMode.equals(C2U("dirty")) ) { - //@todo reselect object - m_aSelectedObjectCID = C2U(""); + //the view has become dirty, we should repaint it if we have a window + if( m_pChartWindow ) + m_pChartWindow->Invalidate(); } -} + else if( rEvent.NewMode.equals(C2U("invalid")) ) + { + //the view is about to become invalid so end all actions on it + impl_invalidateAccessible(); + ::vos::OGuard aGuard( Application::GetSolarMutex()); + if( m_pDrawViewWrapper && m_pDrawViewWrapper->IsTextEdit() ) + this->EndTextEdit(); + if( m_pDrawViewWrapper ) + m_pDrawViewWrapper->UnmarkAll(); + //m_pDrawViewWrapper->hideMarkHandles(); todo?? + } + else + { + //the view was rebuild so we can start some actions on it again + if( !m_bConnectingToView ) + { + if(m_pChartWindow && m_aModel.is() ) + { + m_bConnectingToView = true; -void SAL_CALL ChartController -::impl_deleteView() - throw(uno::RuntimeException) -{ - if( m_pDrawViewWrapper && m_pDrawViewWrapper->IsTextEdit() ) - this->EndTextEdit(); - if( m_pDrawViewWrapper ) - m_pDrawViewWrapper->hideMarkHandles(); + GetDrawModelWrapper(); + if(m_pDrawModelWrapper) + { + { + ::vos::OGuard aGuard( Application::GetSolarMutex()); + if( m_pDrawViewWrapper ) + m_pDrawViewWrapper->ReInit(); + } - DELETEZ( m_pDrawViewWrapper ); - delete m_pChartView; m_pChartView = NULL; -} + //reselect object + if( m_aSelection.hasSelection() ) + this->impl_selectObjectAndNotiy(); - sal_Bool SAL_CALL ChartController -::impl_tryInitializeView() - throw(uno::RuntimeException) -{ - osl::ClearableGuard< osl::Mutex > aGuard( m_aControllerMutex ); - if(!m_pChartWindow || !m_aModel.is() ) - return sal_False; - - if( !m_pDrawModelWrapper ) - m_pDrawModelWrapper = new DrawModelWrapper(m_xCC - ,wrapper::SchItemPool::CreateSchItemPool()); - - uno::Reference< frame::XModel > xDrawModel = m_pDrawModelWrapper->getUnoModel(); - if( xDrawModel.is()) - xDrawModel->lockControllers(); - - impl_deleteView(); - m_pChartView = ChartView::createView( m_xCC, m_aModel->getModel() - , uno::Reference<drawing::XDrawPagesSupplier>::query( xDrawModel ) - , m_pNumberFormatterWrapper ); - //OutputDevice* pOutDev = m_pDrawViewWrapper->GetWin(0); - Size aPageSize = m_pChartWindow->GetOutputSize(); - m_pChartView->create( awt::Size( aPageSize.Width(), aPageSize.Height() ) ); -// m_pChartWindow->SetChartView(m_pChartView);//enable event flow from window to View (Window knows View) - - //create draw view: - if(!m_pDrawViewWrapper) - m_pDrawViewWrapper = new DrawViewWrapper(&m_pDrawModelWrapper->getSdrModel(),m_pChartWindow); - else - m_pDrawViewWrapper->ReInit();//this does not work properly for unknown reasons (after some tiny resizes their seems to went something very wrong: mouse click to view -> crash ) - //test: - //Rectangle aTest = m_pDrawViewWrapper->GetWorkArea(); - //m_pDrawViewWrapper->SetWorkArea(pOutDev->PixelToLogic(Rectangle(rOfs, rSize))); + impl_initializeAccessible(); - if( xDrawModel.is()) - { - xDrawModel->unlockControllers(); - m_pChartWindow->Invalidate(); + if( m_pChartWindow ) + m_pChartWindow->Invalidate(); + } + + m_bConnectingToView = false; + } + } } - return sal_True; } sal_Bool SAL_CALL ChartController ::attachModel( const uno::Reference< frame::XModel > & xModel ) throw(uno::RuntimeException) { + impl_invalidateAccessible(); + //is called to attach the controller to a new model. //return true if attach was successfully, false otherwise (e.g. if you do not work with a model) - osl::ClearableGuard< osl::Mutex > aGuard( m_aControllerMutex ); + ::vos::OClearableGuard aGuard( Application::GetSolarMutex()); if( impl_isDisposedOrSuspended() ) //@todo? allow attaching a new model while suspended? return sal_False; //behave passive if already disposed or suspended aGuard.clear(); @@ -531,22 +575,55 @@ void SAL_CALL ChartController //--handle relations to the old model if any if( aOldModelRef.is() ) { + uno::Reference< util::XModeChangeBroadcaster > xViewBroadcaster( m_xChartView, uno::UNO_QUERY ); + if( xViewBroadcaster.is() ) + xViewBroadcaster->removeModeChangeListener(this); + m_pDrawModelWrapper.reset(); + aOldModelRef->removeListener( this ); //@todo?? termination correct? - aOldModelRef->tryTermination(); +// aOldModelRef->tryTermination(); +#ifdef TEST_ENABLE_MODIFY_LISTENER + uno::Reference< util::XModifyBroadcaster > xMBroadcaster( aOldModelRef->getModel(),uno::UNO_QUERY ); + if( xMBroadcaster.is()) + xMBroadcaster->removeModifyListener( this ); +#endif } //--handle relations to the new model aNewModelRef->addListener( this ); - //the frameloader is responsible to call xModel->connectController + // set new model at dispatchers + m_aDispatchContainer.setModel( aNewModelRef->getModel()); + ControllerCommandDispatch * pDispatch = new ControllerCommandDispatch( m_xCC, this ); + pDispatch->initialize(); + + // the dispatch container will return "this" for all commands returned by + // impl_getAvailableCommands(). That means, for those commands dispatch() + // is called here at the ChartController. + m_aDispatchContainer.setFallbackDispatch( pDispatch, impl_getAvailableCommands() ); + +#ifdef TEST_ENABLE_MODIFY_LISTENER + uno::Reference< util::XModifyBroadcaster > xMBroadcaster( aNewModelRef->getModel(),uno::UNO_QUERY ); + if( xMBroadcaster.is()) + xMBroadcaster->addModifyListener( this ); +#endif + uno::Reference< lang::XMultiServiceFactory > xFact( m_aModel->getModel(), uno::UNO_QUERY ); + if( xFact.is()) { - // Indirect calls to VCL - ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); - impl_tryInitializeView(); + m_xChartView = xFact->createInstance( CHART_VIEW_SERVICE_NAME ); + GetDrawModelWrapper(); + uno::Reference< util::XModeChangeBroadcaster > xViewBroadcaster( m_xChartView, uno::UNO_QUERY ); + if( xViewBroadcaster.is() ) + xViewBroadcaster->addModeChangeListener(this); } + + //the frameloader is responsible to call xModel->connectController + if( m_pChartWindow ) + m_pChartWindow->Invalidate(); + return sal_True; } @@ -580,7 +657,7 @@ void SAL_CALL ChartController //set of data that can be used to restore the current view status at later time // by using XController::restoreViewData() - osl::ResettableGuard< osl::Mutex > aGuard( m_aControllerMutex ); + ::vos::OGuard aGuard( Application::GetSolarMutex()); if( impl_isDisposedOrSuspended() ) return uno::Any(); //behave passive if already disposed or suspended //@todo? or throw an exception?? @@ -597,7 +674,7 @@ void SAL_CALL ChartController { //restores the view status using the data gotten from a previous call to XController::getViewData() - osl::ResettableGuard< osl::Mutex > aGuard( m_aControllerMutex ); + ::vos::OGuard aGuard( Application::GetSolarMutex()); if( impl_isDisposedOrSuspended() ) return; //behave passive if already disposed or suspended //@todo? or throw an exception?? @@ -615,15 +692,14 @@ void SAL_CALL ChartController //we may show dialogs here to ask the user for saving changes ... @todo? - osl::ResettableGuard< osl::Mutex > aGuard( m_aControllerMutex ); + ::vos::OGuard aGuard( Application::GetSolarMutex()); if( m_aLifeTimeManager.impl_isDisposed() ) return sal_False; //behave passive if already disposed, return false because request was not accepted //@todo? correct if(bSuspend==m_bSuspended) { OSL_ENSURE( sal_False, "new suspend mode equals old suspend mode" ); - //@todo ??? or return true in this case? - return sal_False; + return sal_True; } //change suspend mode @@ -656,6 +732,30 @@ void SAL_CALL ChartController return sal_True; } + +void ChartController::impl_createDrawViewController() +{ + ::vos::OGuard aGuard( Application::GetSolarMutex()); + if(!m_pDrawViewWrapper) + { + if( m_pDrawModelWrapper ) + { + m_pDrawViewWrapper = new DrawViewWrapper(&m_pDrawModelWrapper->getSdrModel(),m_pChartWindow); + m_pDrawViewWrapper->attachParentReferenceDevice( m_aModel->getModel()); + } + } +} +void ChartController::impl_deleteDrawViewController() +{ + if( m_pDrawViewWrapper ) + { + ::vos::OGuard aGuard( Application::GetSolarMutex()); + if( m_pDrawViewWrapper->IsTextEdit() ) + this->EndTextEdit(); + DELETEZ( m_pDrawViewWrapper ); + } +} + //----------------------------------------------------------------- // XComponent (base of XController) //----------------------------------------------------------------- @@ -663,43 +763,93 @@ void SAL_CALL ChartController void SAL_CALL ChartController ::dispose() throw(uno::RuntimeException) { - //This object should release all resources and references in the - //easiest possible manner - //This object must notify all registered listeners using the method - //<member>XEventListener::disposing</member> + try + { + //This object should release all resources and references in the + //easiest possible manner + //This object must notify all registered listeners using the method + //<member>XEventListener::disposing</member> - //hold no mutex - if( !m_aLifeTimeManager.dispose() ) - return; + //hold no mutex + if( !m_aLifeTimeManager.dispose() ) + return; - OSL_ENSURE( m_bSuspended, "dispose was called but controller is not suspended" ); +// OSL_ENSURE( m_bSuspended, "dispose was called but controller is not suspended" ); - //--release all resources and references + this->stopDoubleClickWaiting(); - impl_deleteView(); - DELETEZ( m_pDrawViewWrapper ); - DELETEZ( m_pDrawModelWrapper ); - m_pChartWindow = NULL;//m_pChartWindow is deleted via UNO by Window hierarchy or Framework + // clear selection (and therefore range highlighting) + this->select( uno::Any()); - m_xFrame = NULL; - TheModelRef aModelRef( m_aModel, m_aModelMutex); - m_aModel = NULL; + //--release all resources and references + { + uno::Reference< util::XModeChangeBroadcaster > xViewBroadcaster( m_xChartView, uno::UNO_QUERY ); + if( xViewBroadcaster.is() ) + xViewBroadcaster->removeModeChangeListener(this); + // /-- + impl_invalidateAccessible(); + ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); + impl_deleteDrawViewController(); + m_pDrawModelWrapper.reset(); + + m_apDropTargetHelper.reset(); + + //the accessible view is disposed within window destructor of m_pChartWindow + m_pChartWindow->clear(); + m_pChartWindow = NULL;//m_pChartWindow is deleted via UNO due to dispose of m_xViewWindow (trigerred by Framework (Controller pretends to be XWindow also)) + m_xViewWindow->dispose(); + // \-- + } - if(aModelRef.is()) + // remove as listener to layout manager events + if( m_xLayoutManagerEventBroadcaster.is()) + { + m_xLayoutManagerEventBroadcaster->removeLayoutManagerEventListener( this ); + m_xLayoutManagerEventBroadcaster.set( 0 ); + } + + m_xFrame = NULL; + uno::Reference< frame::XModel > xModel( m_aModel->getModel() ); + if(xModel.is()) + xModel->disconnectController( uno::Reference< frame::XController >( this )); + + TheModelRef aModelRef( m_aModel, m_aModelMutex); + m_aModel = NULL; + + if(aModelRef.is()) + { + aModelRef->removeListener( this ); +#ifdef TEST_ENABLE_MODIFY_LISTENER + try + { + uno::Reference< util::XModifyBroadcaster > xMBroadcaster( aModelRef->getModel(),uno::UNO_QUERY ); + if( xMBroadcaster.is()) + xMBroadcaster->removeModifyListener( this ); + } + catch( const uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } +#endif + aModelRef->tryTermination(); + } + + //// @todo integrate specialized implementation + //e.g. release further resources and references + + m_aDispatchContainer.DisposeAndClear(); + } + catch( const uno::Exception & ex ) { - aModelRef->removeListener( this ); - aModelRef->tryTermination(); + ASSERT_EXCEPTION( ex ); } - - //// @todo integrate specialized implementation - //e.g. release further resources and references } void SAL_CALL ChartController ::addEventListener( const uno::Reference<lang::XEventListener>& xListener ) throw(uno::RuntimeException) { - osl::Guard< osl::Mutex > aGuard( m_aControllerMutex ); + ::vos::OGuard aGuard( Application::GetSolarMutex()); if( impl_isDisposedOrSuspended() )//@todo? allow adding of listeners in suspend mode? return; //behave passive if already disposed or suspended @@ -712,8 +862,8 @@ void SAL_CALL ChartController lang::XEventListener>& xListener ) throw(uno::RuntimeException) { - osl::Guard< osl::Mutex > aGuard( m_aControllerMutex ); - if( impl_isDisposedOrSuspended() ) //@todo? allow removing of listeners in suspend mode? + ::vos::OGuard aGuard( Application::GetSolarMutex()); + if( m_aLifeTimeManager.impl_isDisposed() ) return; //behave passive if already disposed or suspended //--remove listener @@ -763,22 +913,25 @@ void SAL_CALL ChartController //Listener should deregister himself and relaese all references to the closing object. TheModelRef aModelRef( 0, m_aModelMutex); + if( impl_releaseThisModel( rSource.Source ) ) + { + //--stop listening to the closing model + aModelRef->removeListener( this ); + } +} + +bool ChartController::impl_releaseThisModel( const uno::Reference< uno::XInterface > & xModel ) +{ bool bReleaseModel = sal_False; { ::osl::Guard< ::osl::Mutex > aGuard( m_aModelMutex ); - aModelRef = m_aModel; - if( aModelRef.is() && aModelRef->getModel() == rSource.Source ) + if( m_aModel.is() && m_aModel->getModel() == xModel ) { m_aModel = NULL; - bReleaseModel = sal_True; + bReleaseModel = true; } } - //@todo ?? why remove the listener??? this could be handled by the closing object - if( bReleaseModel ) - { - //--stop listening to the closing model - aModelRef->removeListener( this ); - } + return bReleaseModel; } //----------------------------------------------------------------- @@ -788,45 +941,66 @@ void SAL_CALL ChartController ::disposing( const lang::EventObject& rSource ) throw(uno::RuntimeException) { - notifyClosing(rSource); + if( !impl_releaseThisModel( rSource.Source )) + { + if( rSource.Source == m_xLayoutManagerEventBroadcaster ) + m_xLayoutManagerEventBroadcaster.set( 0 ); + } } +void SAL_CALL ChartController::layoutEvent( const lang::EventObject& aSource, ::sal_Int16 eLayoutEvent, const uno::Any& aInfo ) + throw (uno::RuntimeException) +{ + if( eLayoutEvent == frame::LayoutManagerEvents::MERGEDMENUBAR ) + { + Reference< frame::XLayoutManager > xLM( aSource.Source, uno::UNO_QUERY ); + if( xLM.is()) + { + xLM->createElement( C2U("private:resource/statusbar/statusbar")); + xLM->requestElement( C2U("private:resource/statusbar/statusbar")); + } + } +} + + //----------------------------------------------------------------- // XDispatchProvider (required interface) //----------------------------------------------------------------- -bool isFormatObjectSID( sal_Int32 nSlotID ) +namespace { - switch( nSlotID ) - { - case SID_DIAGRAM_TITLE_MAIN: - case SID_DIAGRAM_TITLE_SUB: - case SID_DIAGRAM_TITLE_X: - case SID_DIAGRAM_TITLE_Y: - case SID_DIAGRAM_TITLE_Z: - case SID_DIAGRAM_TITLE_ALL: - case SID_LEGEND: - case SID_DIAGRAM_AXIS_X: - case SID_DIAGRAM_AXIS_Y: - case SID_DIAGRAM_AXIS_Z: - case SID_DIAGRAM_AXIS_A: // secondary x-axis - case SID_DIAGRAM_AXIS_B: // secondary y-axis - case SID_DIAGRAM_AXIS_ALL: - case SID_DIAGRAM_GRID_X_MAIN: - case SID_DIAGRAM_GRID_Y_MAIN: - case SID_DIAGRAM_GRID_Z_MAIN: - case SID_DIAGRAM_GRID_X_HELP: - case SID_DIAGRAM_GRID_Y_HELP: - case SID_DIAGRAM_GRID_Z_HELP: - case SID_DIAGRAM_GRID_ALL: - case SID_DIAGRAM_WALL: - case SID_DIAGRAM_FLOOR: - case SID_DIAGRAM_AREA: - return true; - } - +bool lcl_isFormatObjectCommand( const rtl::OString& aCommand ) +{ + if( aCommand.equals("MainTitle") + || aCommand.equals("SubTitle") + || aCommand.equals("XTitle") + || aCommand.equals("YTitle") + || aCommand.equals("ZTitle") + || aCommand.equals("AllTitles") + || aCommand.equals("Legend") + || aCommand.equals("DiagramAxisX") + || aCommand.equals("DiagramAxisY") + || aCommand.equals("DiagramAxisZ") + || aCommand.equals("DiagramAxisA") + || aCommand.equals("DiagramAxisB") + || aCommand.equals("DiagramAxisAll") + || aCommand.equals("DiagramGridXMain") + || aCommand.equals("DiagramGridYMain") + || aCommand.equals("DiagramGridZMain") + || aCommand.equals("DiagramGridXHelp") + || aCommand.equals("DiagramGridYHelp") + || aCommand.equals("DiagramGridZHelp") + || aCommand.equals("DiagramGridAll") + || aCommand.equals("DiagramWall") + || aCommand.equals("DiagramFloor") + || aCommand.equals("DiagramArea") + ) + return true; + + // else return false; } +} // anonymous namespace uno::Reference<frame::XDispatch> SAL_CALL ChartController ::queryDispatch( const util::URL& rURL @@ -834,85 +1008,25 @@ bool isFormatObjectSID( sal_Int32 nSlotID ) , sal_Int32 nSearchFlags) throw(uno::RuntimeException) { - //// @todo integrate specialized implementation - //decide which commands you can handle - if ( !m_aLifeTimeManager.impl_isDisposed() ) { - //@todo avoid OString (see Mathias mail on bug #104387#) - rtl::OString aCommand( rtl::OUStringToOString( rURL.Path, RTL_TEXTENCODING_ASCII_US ) ); - if( aCommand.equals("Save") - || aCommand.equals("SaveAs") - || aCommand.equals("SaveAll") - - || aCommand.equals("Undo") - || aCommand.equals("Cut") - || aCommand.equals("Copy") - || aCommand.equals("Paste") - || aCommand.equals("SelectAll") - || aCommand.equals("Close") - || aCommand.equals("TESTTEST") - || aCommand.equals("slot:23") - //|| aCommand.copy(0,4).EqualsAscii("Bib/") - //|| aURL.Complete.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("slot:5503")) - ) - { - //@todo create a seperate dispatcher object or implement XDispatch interface by yourself - //to return it here - return static_cast< frame::XDispatch* >( this ); - } - else if(rURL.Protocol.equalsIgnoreAsciiCase( C2U("slot:") ) ) - { - sal_Int32 nSlotID = rURL.Path.toInt32(); - if( SID_DIAGRAM_OBJECTS == nSlotID - || SID_DIAGRAM_TYPE == nSlotID - || SID_INSERT_TITLE == nSlotID - || SID_INSERT_CHART_LEGEND == nSlotID - || SID_INSERT_DESCRIPTION == nSlotID - || SID_INSERT_AXIS == nSlotID - || SID_INSERT_GRIDS == nSlotID - || SID_INSERT_STATISTICS == nSlotID - || SID_CHARMAP == nSlotID - || SID_TEXTEDIT == nSlotID - || isFormatObjectSID(nSlotID) - || SID_3D_VIEW == nSlotID - || SID_ATTR_TRANSFORM == nSlotID - || SID_DIAGRAM_DATA == nSlotID - ) - { - return static_cast< frame::XDispatch* >( this ); - } - } + if( rTargetFrameName.getLength() && + rTargetFrameName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("_self"))) + return m_aDispatchContainer.getDispatchForURL( rURL ); } return uno::Reference< frame::XDispatch > (); } -/* -typedef ::std::map< sal_Int32, ::rtl::OUString > tSlotIdCommandMap; -typedef ::comphelper::MakeMap< sal_Int32, ::rtl::OUString > tMakeSlotIdCommandMap; -tMakeSlotIdCommandMap m_aSlotIdCommandMap = - tMakeSlotIdCommandMap - ( (sal_Int32)SID_DIAGRAM_TITLE_MAIN, C2U( "slot:" )+=rtl::OUString::valueOf( (sal_Int32)SID_DIAGRAM_TITLE_MAIN ) ) - ; -*/ + uno::Sequence<uno::Reference<frame::XDispatch > > ChartController ::queryDispatches( const uno::Sequence< frame::DispatchDescriptor>& xDescripts) throw(uno::RuntimeException) { - sal_Int32 nCount = xDescripts.getLength(); - - if( !nCount ) - return uno::Sequence<uno::Reference<frame::XDispatch > > (); - - uno::Sequence<uno::Reference<frame::XDispatch > > aRet( nCount ); - for( sal_Int32 nPos = 0; nPos<nCount; ++nPos ) + if ( !m_aLifeTimeManager.impl_isDisposed() ) { - aRet[ nPos ] = queryDispatch( - xDescripts[nPos].FeatureURL - , xDescripts[nPos].FrameName - , xDescripts[nPos].SearchFlags ); + return m_aDispatchContainer.getDispatchesForURLs( xDescripts ); } - return aRet; + return uno::Sequence<uno::Reference<frame::XDispatch > > (); } //----------------------------------------------------------------- @@ -926,109 +1040,99 @@ tMakeSlotIdCommandMap m_aSlotIdCommandMap = { //@todo avoid OString (see Mathias mail on bug #104387#) rtl::OString aCommand( rtl::OUStringToOString( rURL.Path, RTL_TEXTENCODING_ASCII_US ) ); - //test only - if(aCommand.equals("TESTTEST") - || aCommand.equals("Undo") ) - { - Window* pWindow = m_pChartWindow; - Rectangle aRect( Point(0,0), pWindow->GetOutputSize() ); - Region aRegion( aRect ); - m_pDrawViewWrapper->CompleteRedraw(pWindow, aRegion ); - - /* - INVALIDATE_CHILDREN - INVALIDATE_NOCHILDREN - INVALIDATE_NOERASE - INVALIDATE_UPDATE - INVALIDATE_TRANSPARENT - INVALIDATE_NOTRANSPARENT - INVALIDATE_NOCLIPCHILDREN - */ - //Invalidate(INVALIDATE_UPDATE); - } - else if(aCommand.equals("Save")) + if(aCommand.equals("Paste")) + this->executeDispatch_Paste(); + else if(aCommand.equals("Copy")) + this->executeDispatch_Copy(); + else if(aCommand.equals("Cut")) + this->executeDispatch_Cut(); + else if(aCommand.equals("DataRanges")) { //only test: - impl_rebuildView(); +// this->executeDispatch_ObjectToDefault(); + this->executeDispatch_SourceData(); } - else if(aCommand.equals("SaveAs")) + //---------------------------------- + else if(aCommand.equals("Update")) //Update Chart { - //only test: - this->executeDispatch_ObjectToDefault(); + ChartViewHelper::setViewToDirtyState( m_aModel->getModel() ); + if( m_pChartWindow ) + m_pChartWindow->Invalidate(); } - //---------------------------------- - else if(rURL.Protocol.equalsIgnoreAsciiCase( C2U("slot:") ) ) + else if(aCommand.equals("DiagramData")) + this->executeDispatch_EditData(); + //insert objects + else if( aCommand.equals("InsertTitle")) + this->executeDispatch_InsertTitle(); + else if( aCommand.equals("InsertLegend")) + this->executeDispatch_InsertLegend(); + else if( aCommand.equals("InsertDescription")) + this->executeDispatch_InsertDataLabel(); + else if( aCommand.equals("InsertAxis")) + this->executeDispatch_InsertAxis(); + else if( aCommand.equals("InsertGrids")) + this->executeDispatch_InsertGrid(); + else if( aCommand.equals("InsertStatistics")) + this->executeDispatch_InsertStatistic(); + else if( aCommand.equals("InsertSymbol")) + this->executeDispatch_InsertSpecialCharacter(); + //format objects + else if( aCommand.equals("DiagramObjects")) + this->executeDispatch_ObjectProperties(); + else if( aCommand.equals("TransformDialog")) + this->executeDispatch_PositionAndSize(); + else if( lcl_isFormatObjectCommand(aCommand) ) + this->executeDispatch_FormatObject(rURL.Path); + //more format +//MENUCHANGE else if(aCommand.equals("SelectSourceRanges")) +//MENUCHANGE this->executeDispatch_SourceData(); + else if( aCommand.equals("DiagramType")) + this->executeDispatch_ChartType(); + else if( aCommand.equals("View3D")) + this->executeDispatch_View3D(); + else if( aCommand.equals("Forward")) + this->executeDispatch_MoveSeries( sal_True ); + else if( aCommand.equals("Backward")) + this->executeDispatch_MoveSeries( sal_False ); + else if( aCommand.equals("NewArrangement")) + this->executeDispatch_NewArrangement(); + else if( aCommand.equals("ToggleLegend")) + this->executeDispatch_ToggleLegend(); + else if( aCommand.equals("ToggleGridHorizontal")) + this->executeDispatch_ToggleGridHorizontal(); + else if( aCommand.equals("ScaleText")) + this->executeDispatch_ScaleText(); + else if( aCommand.equals("StatusBarVisible")) { - sal_Int32 nSlotID = rURL.Path.toInt32(); - switch( nSlotID ) + // workaround: this should not be necessary. + uno::Reference< beans::XPropertySet > xPropSet( m_xFrame, uno::UNO_QUERY ); + if( xPropSet.is() ) { - case SID_DIAGRAM_OBJECTS: - this->executeDispatch_ObjectProperties(); - break; - case SID_DIAGRAM_TYPE: - this->executeDispatch_ChartType(); - break; - case SID_INSERT_TITLE: - this->executeDispatch_InsertTitle(); - break; - case SID_INSERT_CHART_LEGEND: - this->executeDispatch_InsertLegend(); - break; - case SID_INSERT_DESCRIPTION: - this->executeDispatch_InsertDataLabel(); - break; - case SID_INSERT_AXIS: - this->executeDispatch_InsertAxis(); - break; - case SID_INSERT_GRIDS: - this->executeDispatch_InsertGrid(); - break; - case SID_INSERT_STATISTICS: - this->executeDispatch_InsertStatistic(); - break; - case SID_CHARMAP: - this->executeDispatch_InsertSpecialCharacter(); - break; - case SID_TEXTEDIT: - this->executeDispatch_EditText(); - break; - case SID_3D_VIEW: - this->executeDispatch_RotateDiagram(); - break; - case SID_ATTR_TRANSFORM: - this->executeDispatch_PositionAndSize( m_aSelectedObjectCID ); - break; - case SID_DIAGRAM_DATA: - this->executeDispatch_EditData(); - break; - - default: - if( isFormatObjectSID(nSlotID) ) + uno::Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager; + xPropSet->getPropertyValue( C2U( "LayoutManager" ) ) >>= xLayoutManager; + if ( xLayoutManager.is() ) + { + bool bIsVisible( xLayoutManager->isElementVisible( C2U("private:resource/statusbar/statusbar"))); + if( bIsVisible ) { - this->executeDispatch_FormatObject(nSlotID); + xLayoutManager->hideElement( C2U( "private:resource/statusbar/statusbar")); + xLayoutManager->destroyElement( C2U( "private:resource/statusbar/statusbar")); } - break; - } - } - else if(aCommand.equals("SaveAll")) - { - if( m_aModel.is()) - { - // initialize doc with default data (file-data provider) - uno::Reference< frame::XLoadable > xLoadable( - m_aModel->getModel(), uno::UNO_QUERY ); - OSL_ASSERT( xLoadable.is()); - xLoadable->initNew(); - - // switch to internal calc-data - uno::Reference< XChartDocument > xChartDoc( xLoadable, uno::UNO_QUERY ); - if( xChartDoc.is()) - xChartDoc->createInternalDataProvider( sal_True ); - - impl_rebuildView(); + else + { + xLayoutManager->createElement( C2U( "private:resource/statusbar/statusbar")); + xLayoutManager->showElement( C2U( "private:resource/statusbar/statusbar")); + } + // @todo: update menu state (checkmark next to "Statusbar"). + } } } + + /* + case SID_TEXTEDIT: + this->executeDispatch_EditText(); + */ } void SAL_CALL ChartController @@ -1036,6 +1140,13 @@ tMakeSlotIdCommandMap m_aSlotIdCommandMap = , const util::URL& aURL ) throw (uno::RuntimeException) { +// // TODO: add listener by URL ! +// ::vos::OGuard aGuard( Application::GetSolarMutex()); +// if( impl_isDisposedOrSuspended() )//@todo? allow adding of listeners in suspend mode? +// return; //behave passive if already disposed or suspended + +// //--add listener +// m_aLifeTimeManager.m_aListenerContainer.addInterface( ::getCppuType( & xControl ), xControl ); } void SAL_CALL ChartController @@ -1043,6 +1154,13 @@ tMakeSlotIdCommandMap m_aSlotIdCommandMap = , const util::URL& aURL ) throw (uno::RuntimeException) { +// // TODO: remove listener by URL ! +// ::vos::OGuard aGuard( Application::GetSolarMutex()); +// if( m_aLifeTimeManager.impl_isDisposed() ) +// return; //behave passive if already disposed or suspended + +// //--remove listener +// m_aLifeTimeManager.m_aListenerContainer.removeInterface( ::getCppuType( & xControl ), xControl ); } //----------------------------------------------------------------- @@ -1073,54 +1191,219 @@ tMakeSlotIdCommandMap m_aSlotIdCommandMap = void SAL_CALL ChartController::executeDispatch_ChartType() { - bool bChanged = false; + UndoLiveUpdateGuard aUndoGuard( ::rtl::OUString( String( SchResId( STR_ACTION_EDIT_CHARTTYPE ))), m_aUndoManager, m_aModel->getModel() ); + + // /-- + ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); + //prepare and open dialog + ChartTypeDialog aDlg( m_pChartWindow, m_aModel->getModel(), m_xCC ); + if( aDlg.Execute() == RET_OK ) + { + impl_adaptDataSeriesAutoResize(); + aUndoGuard.commitAction(); + } + // \-- +} +void SAL_CALL ChartController::executeDispatch_SourceData() +{ //------------------------------------------------------------- //convert properties to ItemSet uno::Reference< XChartDocument > xChartDoc( m_aModel->getModel(), uno::UNO_QUERY ); DBG_ASSERT( xChartDoc.is(), "Invalid XChartDocument" ); if( !xChartDoc.is()) return; - uno::Reference< XDiagram > xDia( xChartDoc->getDiagram() ); - DBG_ASSERT( xDia.is(), "No Diagram set!" ); - uno::Reference< XChartTypeTemplate > xTemplate; + UndoLiveUpdateGuard aUndoGuard( ::rtl::OUString( String( SchResId( STR_ACTION_EDIT_DATA_RANGES ))), + m_aUndoManager, m_aModel->getModel() ); if( xChartDoc.is()) { - uno::Reference< lang::XMultiServiceFactory > xCTManager( xChartDoc->getChartTypeManager(), uno::UNO_QUERY ); - //------------------------------------------------------------- - //prepare and open dialog - Window* pParent( NULL ); - SchDiagramTypeDlg aDlg( pParent, xDia, xCTManager ); - if( aDlg.Execute() == RET_OK && - aDlg.HasChanged() ) + // /-- + ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); + ::chart::DataSourceDialog aDlg( m_pChartWindow, xChartDoc, m_xCC ); + if( aDlg.Execute() == RET_OK ) { - xTemplate.set( aDlg.getTemplate()); - bChanged = true; + impl_adaptDataSeriesAutoResize(); + aUndoGuard.commitAction(); } + // \-- } +} - try +void SAL_CALL ChartController::executeDispatch_MoveSeries( sal_Bool bForward ) +{ + ControllerLockGuard aCLGuard( m_aModel->getModel()); + + //get selected series + ::rtl::OUString aObjectCID(m_aSelection.getSelectedCID()); + uno::Reference< XDataSeries > xGivenDataSeries( ObjectIdentifier::getDataSeriesForCID( //yyy todo also legendentries and labels? + aObjectCID, m_aModel->getModel() ) ); + + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + (bForward ? ActionDescriptionProvider::MOVE_TOTOP : ActionDescriptionProvider::MOVE_TOBOTTOM), + ::rtl::OUString( String( SchResId( STR_OBJECT_DATASERIES )))), + m_aUndoManager, m_aModel->getModel()); + + bool bChanged = DiagramHelper::moveSeries( ChartModelHelper::findDiagram( m_aModel->getModel() ), xGivenDataSeries, bForward ); + if( bChanged ) + aUndoGuard.commitAction(); +} + +// ____ XMultiServiceFactory ____ +uno::Reference< uno::XInterface > SAL_CALL + ChartController::createInstance( const ::rtl::OUString& aServiceSpecifier ) + throw (uno::Exception, + uno::RuntimeException) +{ + uno::Reference< uno::XInterface > xResult; + + if( aServiceSpecifier.equals( CHART_ACCESSIBLE_TEXT_SERVICE_NAME )) + xResult.set( impl_createAccessibleTextContext()); + return xResult; +} + +uno::Reference< uno::XInterface > SAL_CALL + ChartController::createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier, + const uno::Sequence< uno::Any >& Arguments ) + throw (uno::Exception, + uno::RuntimeException) +{ + // ignore Arguments + return createInstance( ServiceSpecifier ); +} + +uno::Sequence< ::rtl::OUString > SAL_CALL + ChartController::getAvailableServiceNames() + throw (uno::RuntimeException) +{ + static uno::Sequence< ::rtl::OUString > aServiceNames; + + if( aServiceNames.getLength() == 0 ) { - //make sure that all objects using m_pDrawModelWrapper or m_pChartView are already deleted - if( bChanged && - xTemplate.is() ) - { - uno::Reference< XDiagram > xNewDia( - xTemplate->createDiagram( - helper::DataSeriesTreeHelper::getDataSeriesFromDiagram( xDia ))); - helper::DiagramHelper::changeDiagram( xDia, xNewDia ); - xChartDoc->setDiagram( xNewDia ); + aServiceNames.realloc(1); + aServiceNames[0] = CHART_ACCESSIBLE_TEXT_SERVICE_NAME; + } + + return aServiceNames; +} + +// ____ XModifyListener ____ +void SAL_CALL ChartController::modified( const lang::EventObject& aEvent ) + throw (uno::RuntimeException) +{ + // the source can also be a subobject of the ChartModel + // @todo: change the source in ChartModel to always be the model itself ? +// if( m_aModel->getModel() == aEvent.Source ) + - impl_rebuildView(); + //todo? update menu states ? +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +DrawModelWrapper* ChartController::GetDrawModelWrapper() +{ + if( !m_pDrawModelWrapper.get() ) + { + ExplicitValueProvider* pProvider = ExplicitValueProvider::getExplicitValueProvider( m_xChartView ); + if( pProvider ) + m_pDrawModelWrapper = pProvider->getDrawModelWrapper(); + } + return m_pDrawModelWrapper.get(); +} + +uno::Reference< accessibility::XAccessible > ChartController::CreateAccessible() +{ + uno::Reference< accessibility::XAccessible > xResult( + m_xCC->getServiceManager()->createInstanceWithContext( + CHART2_ACCESSIBLE_SERVICE_NAME, m_xCC ), uno::UNO_QUERY ); + + impl_initializeAccessible( uno::Reference< lang::XInitialization >( xResult, uno::UNO_QUERY ) ); + return xResult; +} + +void ChartController::impl_invalidateAccessible() +{ + if( m_pChartWindow ) + { + Reference< lang::XInitialization > xInit( m_pChartWindow->GetAccessible(false), uno::UNO_QUERY ); + if(xInit.is()) + { + uno::Sequence< uno::Any > aArguments(3);//empty arguments -> invalid accessible + xInit->initialize(aArguments); } } - catch( uno::Exception& e) +} +void ChartController::impl_initializeAccessible() +{ + if( m_pChartWindow ) + this->impl_initializeAccessible( Reference< lang::XInitialization >( m_pChartWindow->GetAccessible(false), uno::UNO_QUERY ) ); +} +void ChartController::impl_initializeAccessible( const uno::Reference< lang::XInitialization >& xInit ) +{ + if(xInit.is()) { - ASSERT_EXCEPTION( e ); + uno::Sequence< uno::Any > aArguments(5); + uno::Reference<view::XSelectionSupplier> xSelectionSupplier(this); + aArguments[0]=uno::makeAny(xSelectionSupplier); + uno::Reference<frame::XModel> xModel(m_aModel->getModel()); + aArguments[1]=uno::makeAny(xModel); + aArguments[2]=uno::makeAny(m_xChartView); + uno::Reference< accessibility::XAccessible > xParent; + if( m_pChartWindow ) + { + Window* pParentWin( m_pChartWindow->GetAccessibleParentWindow()); + if( pParentWin ) + xParent.set( pParentWin->GetAccessible()); + } + aArguments[3]=uno::makeAny(xParent); + aArguments[4]=uno::makeAny(m_xViewWindow); + + xInit->initialize(aArguments); } } +::std::set< ::rtl::OUString > ChartController::impl_getAvailableCommands() +{ + return ::comphelper::MakeSet< ::rtl::OUString > + // commands for container forward + ( C2U("AddDirect")) ( C2U("NewDoc")) ( C2U("Open")) + ( C2U("Save")) ( C2U("SaveAs")) ( C2U("SendMail")) + ( C2U("EditDoc")) ( C2U("ExportDirectToPDF")) ( C2U("PrintDefault")) + + // own commands + ( C2U("Cut") ) ( C2U("Copy") ) ( C2U("Paste") ) + ( C2U("DataRanges") ) ( C2U("DiagramData") ) + // insert objects + ( C2U("InsertTitle") ) ( C2U("InsertLegend") ) ( C2U("InsertDescription") ) + ( C2U("InsertAxis") ) ( C2U("InsertGrids") ) ( C2U("InsertStatistics") ) + ( C2U("InsertSymbol") ) + //format objects +//MENUCHANGE ( C2U("SelectSourceRanges") ) + ( C2U("DiagramObjects") ) ( C2U("TransformDialog") ) + ( C2U("DiagramType") ) ( C2U("View3D") ) + ( C2U("Forward") ) ( C2U("Backward") ) + ( C2U("MainTitle") ) ( C2U("SubTitle") ) + ( C2U("XTitle") ) ( C2U("YTitle") ) ( C2U("ZTitle") ) + ( C2U("AllTitles") ) ( C2U("Legend") ) + ( C2U("DiagramAxisX") ) ( C2U("DiagramAxisY") ) ( C2U("DiagramAxisZ") ) + ( C2U("DiagramAxisA") ) ( C2U("DiagramAxisB") ) ( C2U("DiagramAxisAll") ) + ( C2U("DiagramGridXMain") ) ( C2U("DiagramGridYMain") ) ( C2U("DiagramGridZMain") ) + ( C2U("DiagramGridXHelp") ) ( C2U("DiagramGridYHelp") ) ( C2U("DiagramGridZHelp") ) + ( C2U("DiagramGridAll") ) + ( C2U("DiagramWall") ) ( C2U("DiagramFloor") ) ( C2U("DiagramArea") ) + // toolbar commands + ( C2U("ToggleGridHorizontal"))( C2U("ToggleLegend") ) ( C2U("ScaleText") ) + ( C2U("NewArrangement") ) ( C2U("Update") ) + ( C2U("DefaultColors") ) ( C2U("BarWidth") ) ( C2U("NumberOfLines") ) + ( C2U("ArrangeRow") ) + ( C2U("StatusBarVisible") ) + ; +} + //............................................................................. } //namespace chart //............................................................................. |