Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #include "ChartController.hxx"
21 : : #include "servicenames.hxx"
22 : : #include "ResId.hxx"
23 : : #include "dlg_DataSource.hxx"
24 : : #include "ChartModelHelper.hxx"
25 : : #include "ControllerCommandDispatch.hxx"
26 : : #include "Strings.hrc"
27 : : #include "chartview/ExplicitValueProvider.hxx"
28 : : #include "ChartViewHelper.hxx"
29 : :
30 : : #include "ChartWindow.hxx"
31 : : #include "chartview/DrawModelWrapper.hxx"
32 : : #include "DrawViewWrapper.hxx"
33 : : #include "ObjectIdentifier.hxx"
34 : : #include "DiagramHelper.hxx"
35 : : #include "ControllerLockGuard.hxx"
36 : : #include "UndoGuard.hxx"
37 : : #include "ChartDropTargetHelper.hxx"
38 : :
39 : : #include "macros.hxx"
40 : : #include "dlg_CreationWizard.hxx"
41 : : #include "dlg_ChartType.hxx"
42 : : #include "AccessibleChartView.hxx"
43 : : #include "DrawCommandDispatch.hxx"
44 : : #include "ShapeController.hxx"
45 : : #include "UndoActions.hxx"
46 : :
47 : : #include <comphelper/InlineContainer.hxx>
48 : :
49 : : #include <com/sun/star/awt/PosSize.hpp>
50 : : #include <com/sun/star/chart2/XChartDocument.hpp>
51 : : #include <com/sun/star/chart2/data/XDataReceiver.hpp>
52 : : #include <com/sun/star/frame/XLoadable.hpp>
53 : : #include <com/sun/star/util/XCloneable.hpp>
54 : : #include <com/sun/star/embed/XEmbeddedClient.hpp>
55 : : #include <com/sun/star/util/XModeChangeBroadcaster.hpp>
56 : : #include <com/sun/star/util/XModifyBroadcaster.hpp>
57 : : #include <com/sun/star/frame/LayoutManagerEvents.hpp>
58 : : #include <com/sun/star/document/XUndoManagerSupplier.hpp>
59 : : #include <com/sun/star/document/XUndoAction.hpp>
60 : :
61 : : //-------
62 : : // header for define RET_OK
63 : : #include <vcl/msgbox.hxx>
64 : : //-------
65 : :
66 : : //-------
67 : : #include <toolkit/awt/vclxwindow.hxx>
68 : : #include <toolkit/helper/vclunohelper.hxx>
69 : : #include <vcl/svapp.hxx>
70 : : #include <osl/mutex.hxx>
71 : : //-------
72 : : #include <com/sun/star/frame/XLayoutManager.hpp>
73 : : #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
74 : :
75 : : // this is needed to properly destroy the auto_ptr to the AcceleratorExecute
76 : : // object in the DTOR
77 : : #include <svtools/acceleratorexecute.hxx>
78 : : #include <svx/ActionDescriptionProvider.hxx>
79 : : #include <tools/diagnose_ex.h>
80 : :
81 : : // enable the following define to let the controller listen to model changes and
82 : : // react on this by rebuilding the view
83 : : #define TEST_ENABLE_MODIFY_LISTENER
84 : :
85 : : //.............................................................................
86 : : namespace chart
87 : : {
88 : : //.............................................................................
89 : :
90 : : using namespace ::com::sun::star;
91 : : using namespace ::com::sun::star::accessibility;
92 : : using namespace ::com::sun::star::chart2;
93 : : using ::com::sun::star::uno::Any;
94 : : using ::com::sun::star::uno::Reference;
95 : : using ::com::sun::star::uno::Sequence;
96 : : DBG_NAME(ChartController)
97 : : //-----------------------------------------------------------------
98 : : // ChartController Constructor and Destructor
99 : : //-----------------------------------------------------------------
100 : :
101 : 34 : ChartController::ChartController(uno::Reference<uno::XComponentContext> const & xContext)
102 : : : m_aLifeTimeManager( NULL )
103 : : , m_bSuspended( sal_False )
104 : : , m_bCanClose( sal_True )
105 : : , m_xCC(xContext) //@todo is it allowed to hold this context??
106 : : , m_xFrame( NULL )
107 : : , m_aModelMutex()
108 : : , m_aModel( NULL, m_aModelMutex )
109 : : , m_pChartWindow( NULL )
110 : : , m_xViewWindow()
111 : : , m_xChartView()
112 : : , m_pDrawModelWrapper()
113 : : , m_pDrawViewWrapper(NULL)
114 : : , m_eDragMode(SDRDRAG_MOVE)
115 : : , m_bWaitingForDoubleClick(false)
116 : : , m_bWaitingForMouseUp(false)
117 : : , m_bConnectingToView(false)
118 : : , m_xUndoManager( 0 )
119 : : , m_aDispatchContainer( m_xCC, this )
120 [ + - ][ + - ]: 34 : , m_eDrawMode( CHARTDRAW_SELECT )
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
121 : : {
122 : : DBG_CTOR(ChartController,NULL);
123 [ + - ]: 34 : m_aDoubleClickTimer.SetTimeoutHdl( LINK( this, ChartController, DoubleClickWaitingHdl ) );
124 : 34 : }
125 : :
126 [ + - ][ + - ]: 34 : ChartController::~ChartController()
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
127 : : {
128 : : DBG_DTOR(ChartController,NULL);
129 [ + - ]: 34 : stopDoubleClickWaiting();
130 [ - + ]: 68 : }
131 : :
132 : : //-----------------------------------------------------------------
133 : :
134 : 34 : ChartController::RefCountable::RefCountable() : m_nRefCount(0)
135 : : {
136 : 34 : }
137 : :
138 : 34 : ChartController::RefCountable::~RefCountable()
139 : : {
140 [ - + ]: 34 : }
141 : 16142 : void ChartController::RefCountable::acquire()
142 : : {
143 : 16142 : m_nRefCount++;
144 : 16142 : }
145 : 16142 : void ChartController::RefCountable::release()
146 : : {
147 : 16142 : m_nRefCount--;
148 [ + + ]: 16142 : if(!m_nRefCount)
149 [ + - ]: 34 : delete this;
150 : 16142 : }
151 : :
152 : : //-----------------------------------------------------------------
153 : :
154 : 34 : ChartController::TheModel::TheModel( const uno::Reference< frame::XModel > & xModel )
155 : : : m_xModel( xModel )
156 : : , m_xCloseable( NULL )
157 : : , m_bOwnership( sal_True )
158 [ + - ]: 34 : , m_bOwnershipIsWellKnown( sal_False )
159 : : {
160 : : m_xCloseable =
161 [ + - ][ + - ]: 34 : uno::Reference< util::XCloseable >( xModel, uno::UNO_QUERY );
162 : 34 : }
163 : :
164 : 34 : ChartController::TheModel::~TheModel()
165 : : {
166 [ - + ]: 68 : }
167 : :
168 : 0 : void ChartController::TheModel::SetOwnerShip( sal_Bool bGetsOwnership )
169 : : {
170 : 0 : m_bOwnership = bGetsOwnership;
171 : 0 : m_bOwnershipIsWellKnown = sal_True;
172 : 0 : }
173 : :
174 : 34 : void ChartController::TheModel::addListener( ChartController* pController )
175 : : {
176 [ + - ]: 34 : if(m_xCloseable.is())
177 : : {
178 : : //if you need to be able to veto against the destruction of the model
179 : : // you must add as a close listener
180 : :
181 : : //otherwise you 'can' add as closelistener or 'must' add as dispose event listener
182 : :
183 : 34 : m_xCloseable->addCloseListener(
184 [ + - ][ + - ]: 34 : static_cast<util::XCloseListener*>(pController) );
185 : : }
186 [ # # ]: 0 : else if( m_xModel.is() )
187 : : {
188 : : //we need to add as dispose event listener
189 : 0 : m_xModel->addEventListener(
190 [ # # ][ # # ]: 0 : static_cast<util::XCloseListener*>(pController) );
191 : : }
192 : :
193 : 34 : }
194 : :
195 : 32 : void ChartController::TheModel::removeListener( ChartController* pController )
196 : : {
197 [ + - ]: 32 : if(m_xCloseable.is())
198 : 32 : m_xCloseable->removeCloseListener(
199 [ + - ][ + - ]: 32 : static_cast<util::XCloseListener*>(pController) );
200 : :
201 [ # # ]: 0 : else if( m_xModel.is() )
202 : 0 : m_xModel->removeEventListener(
203 [ # # ][ # # ]: 0 : static_cast<util::XCloseListener*>(pController) );
204 : 32 : }
205 : :
206 : 2 : void ChartController::TheModel::tryTermination()
207 : : {
208 [ - + ]: 2 : if(!m_bOwnership)
209 : 0 : return;
210 : :
211 : : try
212 : : {
213 [ + - ]: 2 : if(m_xCloseable.is())
214 : : {
215 : : try
216 : : {
217 : : //@todo ? are we allowed to use sal_True here if we have the explicit ownership?
218 : : //I think yes, because there might be other closelistners later in the list which might be interested still
219 : : //but make sure that we do not throw the CloseVetoException here ourselfs
220 : : //so stop listening before trying to terminate or check the source of queryclosing event
221 [ + - ][ - + ]: 2 : m_xCloseable->close(sal_True);
222 : :
223 : 0 : m_bOwnership = false;
224 : 0 : m_bOwnershipIsWellKnown = sal_True;
225 : : }
226 [ + - # # ]: 2 : catch( const util::CloseVetoException& )
227 : : {
228 : : //since we have indicated to give up the ownership with paramter true in close call
229 : : //the one who has thrown the CloseVetoException is the new owner
230 : :
231 : : #if OSL_DEBUG_LEVEL > 1
232 : : OSL_ENSURE( !m_bOwnership,
233 : : "INFO: a well known owner has caught a CloseVetoException after calling close(true)" );
234 : : #endif
235 : :
236 : 2 : m_bOwnership = false;
237 : 2 : m_bOwnershipIsWellKnown = sal_True;
238 : : return;
239 : : }
240 : :
241 : : }
242 [ # # ]: 0 : else if( m_xModel.is() )
243 : : {
244 : : //@todo correct??
245 [ # # ][ # # ]: 0 : m_xModel->dispose();
246 [ - + ]: 4 : return;
247 : : }
248 : : }
249 : 0 : catch(const uno::Exception& ex)
250 : : {
251 : : (void)(ex); // no warning in non-debug builds
252 : : OSL_FAIL( ( rtl::OString("Termination of model failed: ")
253 : : + rtl::OUStringToOString( ex.Message, RTL_TEXTENCODING_ASCII_US ) ).getStr() );
254 : : }
255 : : }
256 : :
257 : : //-----------------------------------------------------------------
258 : :
259 : 68 : ChartController::TheModelRef::TheModelRef( TheModel* pTheModel, ::osl::Mutex& rMutex )
260 : 68 : : m_pTheModel(pTheModel), m_rModelMutex(rMutex)
261 : : {
262 [ + - ]: 68 : ::osl::Guard< ::osl::Mutex > aGuard( m_rModelMutex );
263 [ + + ]: 68 : if(m_pTheModel)
264 [ + - ]: 68 : m_pTheModel->acquire();
265 : 68 : }
266 : 16544 : ChartController::TheModelRef::TheModelRef( const TheModelRef& rTheModel, ::osl::Mutex& rMutex )
267 : 16544 : : m_rModelMutex(rMutex)
268 : : {
269 [ + - ]: 16544 : ::osl::Guard< ::osl::Mutex > aGuard( m_rModelMutex );
270 : 16544 : m_pTheModel=rTheModel.operator->();
271 [ + + ]: 16544 : if(m_pTheModel)
272 [ + - ]: 16544 : m_pTheModel->acquire();
273 : 16544 : }
274 : 66 : ChartController::TheModelRef& ChartController::TheModelRef::operator=(TheModel* pTheModel)
275 : : {
276 [ + - ]: 66 : ::osl::Guard< ::osl::Mutex > aGuard( m_rModelMutex );
277 [ + + ]: 66 : if(m_pTheModel==pTheModel)
278 : 32 : return *this;
279 [ + - ]: 34 : if(m_pTheModel)
280 [ + - ]: 34 : m_pTheModel->release();
281 : 34 : m_pTheModel=pTheModel;
282 [ - + ]: 34 : if(m_pTheModel)
283 : 0 : m_pTheModel->acquire();
284 [ + - ]: 66 : return *this;
285 : : }
286 : 34 : ChartController::TheModelRef& ChartController::TheModelRef::operator=(const TheModelRef& rTheModel)
287 : : {
288 [ + - ]: 34 : ::osl::Guard< ::osl::Mutex > aGuard( m_rModelMutex );
289 : 34 : TheModel* pNew=rTheModel.operator->();
290 [ - + ]: 34 : if(m_pTheModel==pNew)
291 : 0 : return *this;
292 [ - + ]: 34 : if(m_pTheModel)
293 [ # # ]: 0 : m_pTheModel->release();
294 : 34 : m_pTheModel=pNew;
295 [ + - ]: 34 : if(m_pTheModel)
296 : 34 : m_pTheModel->acquire();
297 [ + - ]: 34 : return *this;
298 : : }
299 : 16612 : ChartController::TheModelRef::~TheModelRef()
300 : : {
301 [ + - ]: 16612 : ::osl::Guard< ::osl::Mutex > aGuard( m_rModelMutex );
302 [ + + ]: 16612 : if(m_pTheModel)
303 [ + - ][ + - ]: 16612 : m_pTheModel->release();
304 [ - + ]: 16612 : }
305 : 17435 : sal_Bool ChartController::TheModelRef::is() const
306 : : {
307 : 17435 : return (m_pTheModel != 0);
308 : : }
309 : :
310 : :
311 : : //-----------------------------------------------------------------
312 : : // private methods
313 : : //-----------------------------------------------------------------
314 : :
315 : 136 : sal_Bool ChartController
316 : : ::impl_isDisposedOrSuspended() const
317 : : {
318 [ - + ]: 136 : if( m_aLifeTimeManager.impl_isDisposed() )
319 : 0 : return sal_True;
320 : :
321 [ - + ]: 136 : if( m_bSuspended )
322 : : {
323 : : OSL_FAIL( "This Controller is suspended" );
324 : 0 : return sal_True;
325 : : }
326 : 136 : return sal_False;
327 : : }
328 : :
329 : : //-----------------------------------------------------------------
330 : : // lang::XServiceInfo
331 : : //-----------------------------------------------------------------
332 : :
333 [ + - ][ + - ]: 29600 : APPHELPER_XSERVICEINFO_IMPL(ChartController,CHART_CONTROLLER_SERVICE_IMPLEMENTATION_NAME)
[ - + ][ + + ]
[ + - ]
334 : :
335 : 7396 : uno::Sequence< rtl::OUString > ChartController
336 : : ::getSupportedServiceNames_Static()
337 : : {
338 : 7396 : uno::Sequence< rtl::OUString > aSNS( 2 );
339 [ + - ][ + - ]: 7396 : aSNS.getArray()[ 0 ] = CHART_CONTROLLER_SERVICE_NAME;
340 [ + - ]: 7396 : aSNS.getArray()[ 1 ] = ::rtl::OUString( "com.sun.star.frame.Controller" );
341 : : //// @todo : add additional services if you support any further
342 : 7396 : return aSNS;
343 : : }
344 : :
345 : : //-----------------------------------------------------------------
346 : : // XController
347 : : //-----------------------------------------------------------------
348 : :
349 : 34 : void SAL_CALL ChartController
350 : : ::attachFrame( const uno::Reference<frame::XFrame>& xFrame )
351 : : throw(uno::RuntimeException)
352 : : {
353 [ + - ]: 34 : SolarMutexGuard aGuard;
354 : :
355 [ + - ][ - + ]: 34 : if( impl_isDisposedOrSuspended() ) //@todo? allow attaching the frame while suspended?
356 : : return; //behave passive if already disposed or suspended
357 : :
358 [ - + ]: 34 : if(m_xFrame.is()) //what happens, if we do have a Frame already??
359 : : {
360 : : //@todo? throw exception?
361 : : OSL_FAIL( "there is already a frame attached to the controller" );
362 : : return;
363 : : }
364 : :
365 : : //--attach frame
366 [ + - ]: 34 : m_xFrame = xFrame; //the frameloader is responsible to call xFrame->setComponent
367 : :
368 : : //add as disposelistener to the frame (due to persistent reference) ??...:
369 : :
370 : : //the frame is considered to be owner of this controller and will live longer than we do
371 : : //the frame or the disposer of the frame has the duty to call suspend and dispose on this object
372 : : //so we do not need to add as lang::XEventListener for DisposingEvents right?
373 : :
374 : : //@todo nothing right???
375 : :
376 : :
377 : :
378 : : //--------------------------------------------------
379 : : //create view @todo is this the correct place here??
380 : :
381 : 34 : Window* pParent = NULL;
382 : : //get the window parent from the frame to use as parent for our new window
383 [ + - ]: 34 : if(xFrame.is())
384 : : {
385 [ + - ][ + - ]: 34 : uno::Reference< awt::XWindow > xContainerWindow = xFrame->getContainerWindow();
386 : 34 : VCLXWindow* pParentComponent = VCLXWindow::GetImplementation(xContainerWindow);
387 [ + - ]: 34 : pParentComponent->setVisible(sal_True);
388 : :
389 [ + - ]: 34 : pParent = VCLUnoHelper::GetWindow( xContainerWindow );
390 : : }
391 : :
392 [ - + ]: 34 : if(m_pChartWindow)
393 : : {
394 : : //@todo delete ...
395 [ # # ]: 0 : m_pChartWindow->clear();
396 : 0 : m_apDropTargetHelper.reset();
397 : : }
398 : : {
399 : : // calls to VCL
400 [ + - ]: 34 : SolarMutexGuard aSolarGuard;
401 [ + - ][ + - ]: 34 : m_pChartWindow = new ChartWindow(this,pParent,pParent?pParent->GetStyle():0);
[ + - ][ + - ]
402 [ + - ]: 34 : m_pChartWindow->SetBackground();//no Background
403 [ + - ][ + - ]: 34 : m_xViewWindow = uno::Reference< awt::XWindow >( m_pChartWindow->GetComponentInterface(), uno::UNO_QUERY );
[ + - ]
404 [ + - ]: 34 : m_pChartWindow->Show();
405 : : m_apDropTargetHelper.reset(
406 : 34 : new ChartDropTargetHelper( m_pChartWindow->GetDropTarget(),
407 [ + - ][ + - ]: 34 : uno::Reference< chart2::XChartDocument >( getModel(), uno::UNO_QUERY )));
[ + - ][ + - ]
[ + - ]
408 : :
409 [ + - ][ + - ]: 34 : impl_createDrawViewController();
410 : : }
411 : :
412 : : //create the menu
413 : : {
414 [ + - ]: 34 : uno::Reference< beans::XPropertySet > xPropSet( xFrame, uno::UNO_QUERY );
415 [ + - ]: 34 : if( xPropSet.is() )
416 : : {
417 : : try
418 : : {
419 : 34 : uno::Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
420 [ + - ][ + - ]: 34 : xPropSet->getPropertyValue( C2U( "LayoutManager" ) ) >>= xLayoutManager;
[ + - ][ + - ]
421 [ + - ]: 34 : if ( xLayoutManager.is() )
422 : : {
423 [ + - ][ + - ]: 34 : xLayoutManager->lock();
424 [ + - ][ + - ]: 34 : xLayoutManager->requestElement( C2U( "private:resource/menubar/menubar" ) );
[ + - ]
425 : : //@todo: createElement should become unnecessary, remove when #i79198# is fixed
426 [ + - ][ + - ]: 34 : xLayoutManager->createElement( C2U( "private:resource/toolbar/standardbar" ) );
[ + - ]
427 [ + - ][ + - ]: 34 : xLayoutManager->requestElement( C2U( "private:resource/toolbar/standardbar" ) );
[ + - ]
428 : : //@todo: createElement should become unnecessary, remove when #i79198# is fixed
429 [ + - ][ + - ]: 34 : xLayoutManager->createElement( C2U( "private:resource/toolbar/toolbar" ) );
[ + - ]
430 [ + - ][ + - ]: 34 : xLayoutManager->requestElement( C2U( "private:resource/toolbar/toolbar" ) );
[ + - ]
431 : :
432 : : // #i12587# support for shapes in chart
433 [ + - ][ + - ]: 34 : xLayoutManager->createElement( C2U( "private:resource/toolbar/drawbar" ) );
[ + - ]
434 [ + - ][ + - ]: 34 : xLayoutManager->requestElement( C2U( "private:resource/toolbar/drawbar" ) );
[ + - ]
435 : :
436 [ + - ][ + - ]: 34 : xLayoutManager->requestElement( C2U( "private:resource/statusbar/statusbar" ) );
[ + - ]
437 [ + - ][ + - ]: 34 : xLayoutManager->unlock();
438 : :
439 : : // add as listener to get notified when
440 [ + - ]: 34 : m_xLayoutManagerEventBroadcaster.set( xLayoutManager, uno::UNO_QUERY );
441 [ + - ]: 34 : if( m_xLayoutManagerEventBroadcaster.is())
442 [ + - ][ + - ]: 34 : m_xLayoutManagerEventBroadcaster->addLayoutManagerEventListener( this );
[ + - ]
443 [ # # ]: 34 : }
444 : : }
445 [ # # ]: 0 : catch( const uno::Exception & ex )
446 : : {
447 : : ASSERT_EXCEPTION( ex );
448 : : }
449 : 34 : }
450 [ + - ][ + - ]: 34 : }
451 : : }
452 : :
453 : : //XModeChangeListener
454 : 3110 : void SAL_CALL ChartController::modeChanged( const util::ModeChangeEvent& rEvent )
455 : : throw ( uno::RuntimeException )
456 : : {
457 : : //adjust controller to view status changes
458 : :
459 [ + + ]: 3110 : if( rEvent.NewMode.equals(C2U("dirty")) )
460 : : {
461 : : //the view has become dirty, we should repaint it if we have a window
462 [ + - ]: 1588 : SolarMutexGuard aGuard;
463 [ + - ]: 1588 : if( m_pChartWindow )
464 [ + - ][ + - ]: 1588 : m_pChartWindow->ForceInvalidate();
465 : : }
466 [ + + ]: 1522 : else if( rEvent.NewMode.equals(C2U("invalid")) )
467 : : {
468 : : //the view is about to become invalid so end all actions on it
469 [ + - ]: 761 : impl_invalidateAccessible();
470 [ + - ]: 761 : SolarMutexGuard aGuard;
471 [ + - ][ + - ]: 761 : if( m_pDrawViewWrapper && m_pDrawViewWrapper->IsTextEdit() )
[ - + ][ - + ]
472 [ # # ]: 0 : this->EndTextEdit();
473 [ + - ]: 761 : if( m_pDrawViewWrapper )
474 : : {
475 [ + - ]: 761 : m_pDrawViewWrapper->UnmarkAll();
476 [ + - ]: 761 : m_pDrawViewWrapper->HideSdrPage();
477 [ + - ]: 761 : }
478 : : }
479 : : else
480 : : {
481 : : //the view was rebuild so we can start some actions on it again
482 [ + - ]: 761 : if( !m_bConnectingToView )
483 : : {
484 [ + - ][ + + ]: 761 : if(m_pChartWindow && m_aModel.is() )
[ + + ]
485 : : {
486 : 749 : m_bConnectingToView = true;
487 : :
488 : 749 : GetDrawModelWrapper();
489 [ + - ]: 749 : if(m_pDrawModelWrapper)
490 : : {
491 : : {
492 [ + - ]: 749 : SolarMutexGuard aGuard;
493 [ + - ]: 749 : if( m_pDrawViewWrapper )
494 [ + - ][ + - ]: 749 : m_pDrawViewWrapper->ReInit();
495 : : }
496 : :
497 : : //reselect object
498 [ + - ]: 749 : if( m_aSelection.hasSelection() )
499 : 749 : this->impl_selectObjectAndNotiy();
500 : : else
501 [ # # ]: 0 : ChartModelHelper::triggerRangeHighlighting( getModel() );
502 : :
503 : 749 : impl_initializeAccessible();
504 : :
505 : : {
506 [ + - ]: 749 : SolarMutexGuard aGuard;
507 [ + - ]: 749 : if( m_pChartWindow )
508 [ + - ][ + - ]: 749 : m_pChartWindow->Invalidate();
509 : : }
510 : : }
511 : :
512 : 749 : m_bConnectingToView = false;
513 : : }
514 : : }
515 : : }
516 : 3110 : }
517 : :
518 : 34 : sal_Bool SAL_CALL ChartController::attachModel( const uno::Reference< frame::XModel > & xModel )
519 : : throw(uno::RuntimeException)
520 : : {
521 [ + - ]: 34 : impl_invalidateAccessible();
522 : :
523 : : //is called to attach the controller to a new model.
524 : : //return true if attach was successfully, false otherwise (e.g. if you do not work with a model)
525 : :
526 [ + - ]: 34 : SolarMutexClearableGuard aClearableGuard;
527 [ + - ][ - + ]: 34 : if( impl_isDisposedOrSuspended() ) //@todo? allow attaching a new model while suspended?
528 : 0 : return sal_False; //behave passive if already disposed or suspended
529 [ + - ]: 34 : aClearableGuard.clear();
530 : :
531 [ + - ][ + - ]: 34 : TheModelRef aNewModelRef( new TheModel( xModel), m_aModelMutex);
[ + - ]
532 [ + - ]: 34 : TheModelRef aOldModelRef(m_aModel,m_aModelMutex);
533 [ + - ]: 34 : m_aModel = aNewModelRef;
534 : :
535 : : //--handle relations to the old model if any
536 [ - + ]: 34 : if( aOldModelRef.is() )
537 : : {
538 [ # # ]: 0 : uno::Reference< util::XModeChangeBroadcaster > xViewBroadcaster( m_xChartView, uno::UNO_QUERY );
539 [ # # ]: 0 : if( xViewBroadcaster.is() )
540 [ # # ][ # # ]: 0 : xViewBroadcaster->removeModeChangeListener(this);
[ # # ]
541 [ # # ]: 0 : m_pDrawModelWrapper.reset();
542 : :
543 [ # # ]: 0 : aOldModelRef->removeListener( this );
544 : : #ifdef TEST_ENABLE_MODIFY_LISTENER
545 [ # # ][ # # ]: 0 : uno::Reference< util::XModifyBroadcaster > xMBroadcaster( aOldModelRef->getModel(),uno::UNO_QUERY );
546 [ # # ]: 0 : if( xMBroadcaster.is())
547 [ # # ][ # # ]: 0 : xMBroadcaster->removeModifyListener( this );
[ # # ]
548 : : #endif
549 : : }
550 : :
551 : : //--handle relations to the new model
552 [ + - ]: 34 : aNewModelRef->addListener( this );
553 : :
554 : : // set new model at dispatchers
555 [ + - ][ + - ]: 34 : m_aDispatchContainer.setModel( aNewModelRef->getModel());
556 [ + - ]: 34 : ControllerCommandDispatch * pDispatch = new ControllerCommandDispatch( m_xCC, this, &m_aDispatchContainer );
557 [ + - ]: 34 : pDispatch->initialize();
558 : :
559 : : // the dispatch container will return "this" for all commands returned by
560 : : // impl_getAvailableCommands(). That means, for those commands dispatch()
561 : : // is called here at the ChartController.
562 [ + - ][ + - ]: 34 : m_aDispatchContainer.setChartDispatch( pDispatch, impl_getAvailableCommands() );
[ + - ][ + - ]
563 : :
564 [ + - ]: 34 : DrawCommandDispatch* pDrawDispatch = new DrawCommandDispatch( m_xCC, this );
565 [ + - ]: 34 : if ( pDrawDispatch )
566 : : {
567 [ + - ]: 34 : pDrawDispatch->initialize();
568 [ + - ]: 34 : m_aDispatchContainer.setDrawCommandDispatch( pDrawDispatch );
569 : : }
570 : :
571 [ + - ]: 34 : ShapeController* pShapeController = new ShapeController( m_xCC, this );
572 [ + - ]: 34 : if ( pShapeController )
573 : : {
574 [ + - ]: 34 : pShapeController->initialize();
575 [ + - ]: 34 : m_aDispatchContainer.setShapeController( pShapeController );
576 : : }
577 : :
578 : : #ifdef TEST_ENABLE_MODIFY_LISTENER
579 [ + - ][ + - ]: 34 : uno::Reference< util::XModifyBroadcaster > xMBroadcaster( aNewModelRef->getModel(),uno::UNO_QUERY );
580 [ + - ]: 34 : if( xMBroadcaster.is())
581 [ + - ][ + - ]: 34 : xMBroadcaster->addModifyListener( this );
[ + - ]
582 : : #endif
583 : :
584 : : //select chart area per default:
585 [ + - ][ + - ]: 34 : select( uno::makeAny( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_PAGE, rtl::OUString() ) ) );
[ + - ]
586 : :
587 [ + - ][ + - ]: 34 : uno::Reference< lang::XMultiServiceFactory > xFact( getModel(), uno::UNO_QUERY );
588 [ + - ]: 34 : if( xFact.is())
589 : : {
590 [ + - ][ + - ]: 34 : m_xChartView = xFact->createInstance( CHART_VIEW_SERVICE_NAME );
[ + - ][ + - ]
591 [ + - ]: 34 : GetDrawModelWrapper();
592 [ + - ]: 34 : uno::Reference< util::XModeChangeBroadcaster > xViewBroadcaster( m_xChartView, uno::UNO_QUERY );
593 [ + - ]: 34 : if( xViewBroadcaster.is() )
594 [ + - ][ + - ]: 34 : xViewBroadcaster->addModeChangeListener(this);
[ + - ]
595 : : }
596 : :
597 : : //the frameloader is responsible to call xModel->connectController
598 : : {
599 [ + - ]: 34 : SolarMutexGuard aGuard;
600 [ - + ]: 34 : if( m_pChartWindow )
601 [ # # ][ + - ]: 34 : m_pChartWindow->Invalidate();
602 : : }
603 : :
604 [ + - ][ + - ]: 34 : uno::Reference< document::XUndoManagerSupplier > xSuppUndo( getModel(), uno::UNO_QUERY_THROW );
605 [ + - ][ + - ]: 34 : m_xUndoManager.set( xSuppUndo->getUndoManager(), uno::UNO_QUERY_THROW );
[ + - ]
606 : :
607 [ + - ][ + - ]: 34 : return sal_True;
[ + - ]
608 : : }
609 : :
610 : 2707 : uno::Reference< frame::XFrame > SAL_CALL ChartController
611 : : ::getFrame() throw(uno::RuntimeException)
612 : : {
613 : : //provides access to owner frame of this controller
614 : : //return the frame containing this controller
615 : :
616 : 2707 : return m_xFrame;
617 : : }
618 : :
619 : 16416 : uno::Reference< frame::XModel > SAL_CALL ChartController
620 : : ::getModel() throw(uno::RuntimeException)
621 : : {
622 : : //provides access to currently attached model
623 : : //returns the currently attached model
624 : :
625 : : //return nothing, if you do not have a model
626 [ + - ]: 16416 : TheModelRef aModelRef( m_aModel, m_aModelMutex);
627 [ + + ]: 16416 : if(aModelRef.is())
628 [ + - ]: 16012 : return aModelRef->getModel();
629 : :
630 [ + - ]: 16416 : return uno::Reference< frame::XModel > ();
631 : : }
632 : :
633 : 0 : uno::Any SAL_CALL ChartController
634 : : ::getViewData() throw(uno::RuntimeException)
635 : : {
636 : : //provides access to current view status
637 : : //set of data that can be used to restore the current view status at later time
638 : : // by using XController::restoreViewData()
639 : :
640 [ # # ]: 0 : SolarMutexGuard aGuard;
641 [ # # ][ # # ]: 0 : if( impl_isDisposedOrSuspended() )
642 : 0 : return uno::Any(); //behave passive if already disposed or suspended //@todo? or throw an exception??
643 : :
644 : : //-- collect current view state
645 : 0 : uno::Any aRet;
646 : : //// @todo integrate specialized implementation
647 : :
648 [ # # ]: 0 : return aRet;
649 : : }
650 : :
651 : 0 : void SAL_CALL ChartController
652 : : ::restoreViewData( const uno::Any& /* Value */ )
653 : : throw(uno::RuntimeException)
654 : : {
655 : : //restores the view status using the data gotten from a previous call to XController::getViewData()
656 : :
657 [ # # ]: 0 : SolarMutexGuard aGuard;
658 [ # # ][ # # ]: 0 : if( impl_isDisposedOrSuspended() )
659 [ # # ][ # # ]: 0 : return; //behave passive if already disposed or suspended //@todo? or throw an exception??
660 : :
661 : : //// @todo integrate specialized implementation
662 : : }
663 : :
664 : 2 : sal_Bool SAL_CALL ChartController
665 : : ::suspend( sal_Bool bSuspend )
666 : : throw(uno::RuntimeException)
667 : : {
668 : : //is called to prepare the controller for closing the view
669 : : //bSuspend==true: force the controller to suspend his work
670 : : //bSuspend==false try to reactivate the controller
671 : : //returns true if request was accepted and of course successfully finished, false otherwise
672 : :
673 : : //we may show dialogs here to ask the user for saving changes ... @todo?
674 : :
675 [ + - ]: 2 : SolarMutexGuard aGuard;
676 [ + - ][ - + ]: 2 : if( m_aLifeTimeManager.impl_isDisposed() )
677 : 0 : return sal_False; //behave passive if already disposed, return false because request was not accepted //@todo? correct
678 : :
679 [ - + ]: 2 : if(bSuspend==m_bSuspended)
680 : : {
681 : : OSL_FAIL( "new suspend mode equals old suspend mode" );
682 : 0 : return sal_True;
683 : : }
684 : :
685 : : //change suspend mode
686 [ + - ]: 2 : if(bSuspend)
687 : : {
688 : 2 : m_bSuspended = bSuspend;
689 : 2 : return sal_True;
690 : : }
691 : : else
692 : : {
693 : 0 : m_bSuspended = bSuspend;
694 : : }
695 [ + - ]: 2 : return sal_True;
696 : : }
697 : :
698 : :
699 : 34 : void ChartController::impl_createDrawViewController()
700 : : {
701 [ + - ]: 34 : SolarMutexGuard aGuard;
702 [ + - ]: 34 : if(!m_pDrawViewWrapper)
703 : : {
704 [ + - ]: 34 : if( m_pDrawModelWrapper )
705 : : {
706 [ + - ][ + - ]: 34 : m_pDrawViewWrapper = new DrawViewWrapper(&m_pDrawModelWrapper->getSdrModel(),m_pChartWindow,true);
[ + - ]
707 [ + - ][ + - ]: 34 : m_pDrawViewWrapper->attachParentReferenceDevice( getModel() );
708 : : }
709 [ + - ]: 34 : }
710 : 34 : }
711 : 34 : void ChartController::impl_deleteDrawViewController()
712 : : {
713 [ + - ]: 34 : if( m_pDrawViewWrapper )
714 : : {
715 [ + - ]: 34 : SolarMutexGuard aGuard;
716 [ + - ][ - + ]: 34 : if( m_pDrawViewWrapper->IsTextEdit() )
717 [ # # ]: 0 : this->EndTextEdit();
718 [ + - ][ + - ]: 34 : DELETEZ( m_pDrawViewWrapper );
[ + - ]
719 : : }
720 : 34 : }
721 : :
722 : : //-----------------------------------------------------------------
723 : : // XComponent (base of XController)
724 : : //-----------------------------------------------------------------
725 : :
726 : 68 : void SAL_CALL ChartController
727 : : ::dispose() throw(uno::RuntimeException)
728 : : {
729 : : try
730 : : {
731 : : //This object should release all resources and references in the
732 : : //easiest possible manner
733 : : //This object must notify all registered listeners using the method
734 : : //<member>XEventListener::disposing</member>
735 : :
736 : : //hold no mutex
737 [ + - ][ + + ]: 68 : if( !m_aLifeTimeManager.dispose() )
738 : 68 : return;
739 : :
740 : : // OSL_ENSURE( m_bSuspended, "dispose was called but controller is not suspended" );
741 : :
742 [ + - ]: 34 : this->stopDoubleClickWaiting();
743 : :
744 : : //end range highlighting
745 [ + + ]: 34 : if( m_aModel.is())
746 : : {
747 : 2 : uno::Reference< view::XSelectionChangeListener > xSelectionChangeListener;
748 [ + - ][ + - ]: 2 : uno::Reference< chart2::data::XDataReceiver > xDataReceiver( getModel(), uno::UNO_QUERY );
749 [ + - ]: 2 : if( xDataReceiver.is() )
750 [ + - ][ + - ]: 2 : xSelectionChangeListener = uno::Reference< view::XSelectionChangeListener >( xDataReceiver->getRangeHighlighter(), uno::UNO_QUERY );
[ + - ][ + - ]
751 [ + - ]: 2 : if( xSelectionChangeListener.is() )
752 : : {
753 [ + - ]: 2 : uno::Reference< frame::XController > xController( this );
754 [ + - ]: 2 : uno::Reference< lang::XComponent > xComp( xController, uno::UNO_QUERY );
755 [ + - ]: 2 : lang::EventObject aEvent( xComp );
756 [ + - ][ + - ]: 2 : xSelectionChangeListener->disposing( aEvent );
[ + - ]
757 : 2 : }
758 : : }
759 : :
760 : : //--release all resources and references
761 : : {
762 [ + - ]: 34 : uno::Reference< util::XModeChangeBroadcaster > xViewBroadcaster( m_xChartView, uno::UNO_QUERY );
763 [ + - ]: 34 : if( xViewBroadcaster.is() )
764 [ + - ][ + - ]: 34 : xViewBroadcaster->removeModeChangeListener(this);
[ + - ]
765 : :
766 [ + - ]: 34 : impl_invalidateAccessible();
767 [ + - ]: 34 : SolarMutexGuard aSolarGuard;
768 [ + - ]: 34 : impl_deleteDrawViewController();
769 [ + - ]: 34 : m_pDrawModelWrapper.reset();
770 : :
771 : 34 : m_apDropTargetHelper.reset();
772 : :
773 : : //the accessible view is disposed within window destructor of m_pChartWindow
774 [ + - ]: 34 : m_pChartWindow->clear();
775 : 34 : m_pChartWindow = NULL;//m_pChartWindow is deleted via UNO due to dispose of m_xViewWindow (trigerred by Framework (Controller pretends to be XWindow also))
776 [ + - ][ + - ]: 34 : m_xViewWindow->dispose();
777 [ + - ]: 34 : m_xChartView.clear();
778 : : }
779 : :
780 : : // remove as listener to layout manager events
781 [ + - ]: 34 : if( m_xLayoutManagerEventBroadcaster.is())
782 : : {
783 [ + - ][ + - ]: 34 : m_xLayoutManagerEventBroadcaster->removeLayoutManagerEventListener( this );
[ + - ]
784 [ + - ]: 34 : m_xLayoutManagerEventBroadcaster.set( 0 );
785 : : }
786 : :
787 : 34 : m_xFrame.clear();
788 : 34 : m_xUndoManager.clear();
789 : :
790 [ + - ]: 34 : TheModelRef aModelRef( m_aModel, m_aModelMutex);
791 [ + - ]: 34 : m_aModel = NULL;
792 : :
793 [ + + ]: 34 : if( aModelRef.is())
794 : : {
795 [ + - ]: 2 : uno::Reference< frame::XModel > xModel( aModelRef->getModel() );
796 [ + - ]: 2 : if(xModel.is())
797 [ + - ][ + - ]: 2 : xModel->disconnectController( uno::Reference< frame::XController >( this ));
[ + - ]
798 : :
799 [ + - ]: 2 : aModelRef->removeListener( this );
800 : : #ifdef TEST_ENABLE_MODIFY_LISTENER
801 : : try
802 : : {
803 [ + - ][ + - ]: 2 : uno::Reference< util::XModifyBroadcaster > xMBroadcaster( aModelRef->getModel(),uno::UNO_QUERY );
804 [ + - ]: 2 : if( xMBroadcaster.is())
805 [ + - ][ + - ]: 2 : xMBroadcaster->removeModifyListener( this );
[ + - ][ # # ]
806 : : }
807 [ # # ]: 0 : catch( const uno::Exception & ex )
808 : : {
809 : : ASSERT_EXCEPTION( ex );
810 : : }
811 : : #endif
812 [ + - ]: 2 : aModelRef->tryTermination();
813 : : }
814 : :
815 : : //// @todo integrate specialized implementation
816 : : //e.g. release further resources and references
817 : :
818 [ + - ][ + - ]: 68 : m_aDispatchContainer.DisposeAndClear();
[ # # ]
819 : : }
820 : 0 : catch( const uno::Exception & ex )
821 : : {
822 : : ASSERT_EXCEPTION( ex );
823 : : }
824 : : }
825 : :
826 : 0 : void SAL_CALL ChartController
827 : : ::addEventListener( const uno::Reference<lang::XEventListener>& xListener )
828 : : throw(uno::RuntimeException)
829 : : {
830 [ # # ]: 0 : SolarMutexGuard aGuard;
831 [ # # ][ # # ]: 0 : if( impl_isDisposedOrSuspended() )//@todo? allow adding of listeners in suspend mode?
832 : 0 : return; //behave passive if already disposed or suspended
833 : :
834 : : //--add listener
835 [ # # ][ # # ]: 0 : m_aLifeTimeManager.m_aListenerContainer.addInterface( ::getCppuType((const uno::Reference< lang::XEventListener >*)0), xListener );
[ # # ][ # # ]
836 : : }
837 : :
838 : 0 : void SAL_CALL ChartController
839 : : ::removeEventListener( const uno::Reference<
840 : : lang::XEventListener>& xListener )
841 : : throw(uno::RuntimeException)
842 : : {
843 [ # # ]: 0 : SolarMutexGuard aGuard;
844 [ # # ][ # # ]: 0 : if( m_aLifeTimeManager.impl_isDisposed(false) )
845 : 0 : return; //behave passive if already disposed or suspended
846 : :
847 : : //--remove listener
848 [ # # ][ # # ]: 0 : m_aLifeTimeManager.m_aListenerContainer.removeInterface( ::getCppuType((const uno::Reference< lang::XEventListener >*)0), xListener );
[ # # ][ # # ]
849 : : }
850 : :
851 : :
852 : : //-----------------------------------------------------------------
853 : : // util::XCloseListener
854 : : //-----------------------------------------------------------------
855 : 30 : void SAL_CALL ChartController
856 : : ::queryClosing( const lang::EventObject& rSource, sal_Bool bGetsOwnership )
857 : : throw(util::CloseVetoException, uno::RuntimeException)
858 : : {
859 : : //do not use the m_aControllerMutex here because this call is not allowed to block
860 : :
861 [ + - ]: 30 : TheModelRef aModelRef( m_aModel, m_aModelMutex);
862 : :
863 [ - + ]: 30 : if( !aModelRef.is() )
864 : : return;
865 : :
866 [ + - ][ + - ]: 30 : if( !(aModelRef->getModel() == rSource.Source) )
[ - + ]
867 : : {
868 : : OSL_FAIL( "queryClosing was called on a controller from an unknown source" );
869 : : return;
870 : : }
871 : :
872 [ - + ]: 30 : if( !m_bCanClose )//@todo tryaqcuire mutex
873 : : {
874 [ # # ]: 0 : if( bGetsOwnership )
875 : : {
876 : 0 : aModelRef->SetOwnerShip( bGetsOwnership );
877 : : }
878 : :
879 [ # # ]: 30 : throw util::CloseVetoException();
880 : : }
881 : : else
882 : : {
883 : : //@ todo prepare to to closing model -> don't start any further hindering actions
884 [ + - ][ + - ]: 30 : }
885 : : }
886 : :
887 : 30 : void SAL_CALL ChartController
888 : : ::notifyClosing( const lang::EventObject& rSource )
889 : : throw(uno::RuntimeException)
890 : : {
891 : : //Listener should deregister himself and relaese all references to the closing object.
892 : :
893 [ + - ]: 30 : TheModelRef aModelRef( m_aModel, m_aModelMutex);
894 [ + - ][ + - ]: 30 : if( impl_releaseThisModel( rSource.Source ) )
895 : : {
896 : : //--stop listening to the closing model
897 [ + - ]: 30 : aModelRef->removeListener( this );
898 : :
899 : : // #i79087# If the model using this controller is closed, the frame is
900 : : // expected to be closed as well
901 [ + - ]: 30 : Reference< util::XCloseable > xFrameCloseable( m_xFrame, uno::UNO_QUERY );
902 [ + - ]: 30 : if( xFrameCloseable.is())
903 : : {
904 : : try
905 : : {
906 [ + - ][ + - ]: 30 : xFrameCloseable->close( sal_False /* DeliverOwnership */ );
907 : 30 : m_xFrame.clear();
908 : : }
909 [ # # ]: 0 : catch( const util::CloseVetoException & )
910 : : {
911 : : // closing was vetoed
912 : : }
913 : 30 : }
914 [ + - ]: 30 : }
915 [ # # ]: 30 : }
916 : :
917 : 126 : bool ChartController::impl_releaseThisModel( const uno::Reference< uno::XInterface > & xModel )
918 : : {
919 : 126 : bool bReleaseModel = sal_False;
920 : : {
921 [ + - ]: 126 : ::osl::Guard< ::osl::Mutex > aGuard( m_aModelMutex );
922 [ + + ][ + - ]: 126 : if( m_aModel.is() && m_aModel->getModel() == xModel )
[ + - ][ + - ]
[ + + ]
[ + + # # ]
923 : : {
924 [ + - ]: 32 : m_aModel = NULL;
925 : 32 : m_xUndoManager.clear();
926 : 32 : bReleaseModel = true;
927 [ + - ]: 126 : }
928 : : }
929 [ + + ]: 126 : if( bReleaseModel )
930 [ + - ]: 32 : m_aDispatchContainer.setModel( 0 );
931 : 126 : return bReleaseModel;
932 : : }
933 : :
934 : : //-----------------------------------------------------------------
935 : : // util::XEventListener (base of XCloseListener)
936 : : //-----------------------------------------------------------------
937 : 96 : void SAL_CALL ChartController
938 : : ::disposing( const lang::EventObject& rSource )
939 : : throw(uno::RuntimeException)
940 : : {
941 [ + + ]: 96 : if( !impl_releaseThisModel( rSource.Source ))
942 : : {
943 [ - + ]: 94 : if( rSource.Source == m_xLayoutManagerEventBroadcaster )
944 : 0 : m_xLayoutManagerEventBroadcaster.set( 0 );
945 : : }
946 : 96 : }
947 : :
948 : 18 : void SAL_CALL ChartController::layoutEvent( const lang::EventObject& aSource, ::sal_Int16 eLayoutEvent, const uno::Any& /* aInfo */ )
949 : : throw (uno::RuntimeException)
950 : : {
951 [ + + ]: 18 : if( eLayoutEvent == frame::LayoutManagerEvents::MERGEDMENUBAR )
952 : : {
953 [ + - ]: 2 : Reference< frame::XLayoutManager > xLM( aSource.Source, uno::UNO_QUERY );
954 [ + - ]: 2 : if( xLM.is())
955 : : {
956 [ + - ][ + - ]: 2 : xLM->createElement( C2U("private:resource/statusbar/statusbar"));
[ + - ]
957 [ + - ][ + - ]: 2 : xLM->requestElement( C2U("private:resource/statusbar/statusbar"));
[ + - ]
958 : 2 : }
959 : : }
960 : 18 : }
961 : :
962 : :
963 : : //-----------------------------------------------------------------
964 : : // XDispatchProvider (required interface)
965 : : //-----------------------------------------------------------------
966 : :
967 : : namespace
968 : : {
969 : 0 : bool lcl_isFormatObjectCommand( const rtl::OString& aCommand )
970 : : {
971 [ # # # # : 0 : if( aCommand.equals("MainTitle")
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # ]
[ # # ][ # # ]
[ # # ]
972 [ # # ][ # # ]: 0 : || aCommand.equals("SubTitle")
973 [ # # ][ # # ]: 0 : || aCommand.equals("XTitle")
974 [ # # ][ # # ]: 0 : || aCommand.equals("YTitle")
975 [ # # ][ # # ]: 0 : || aCommand.equals("ZTitle")
976 [ # # ][ # # ]: 0 : || aCommand.equals("SecondaryXTitle")
977 [ # # ][ # # ]: 0 : || aCommand.equals("SecondaryYTitle")
978 [ # # ][ # # ]: 0 : || aCommand.equals("AllTitles")
979 [ # # ][ # # ]: 0 : || aCommand.equals("DiagramAxisX")
980 [ # # ][ # # ]: 0 : || aCommand.equals("DiagramAxisY")
981 [ # # ][ # # ]: 0 : || aCommand.equals("DiagramAxisZ")
982 [ # # ][ # # ]: 0 : || aCommand.equals("DiagramAxisA")
983 [ # # ][ # # ]: 0 : || aCommand.equals("DiagramAxisB")
984 [ # # ][ # # ]: 0 : || aCommand.equals("DiagramAxisAll")
985 [ # # ][ # # ]: 0 : || aCommand.equals("DiagramGridXMain")
986 [ # # ][ # # ]: 0 : || aCommand.equals("DiagramGridYMain")
987 [ # # ][ # # ]: 0 : || aCommand.equals("DiagramGridZMain")
988 [ # # ][ # # ]: 0 : || aCommand.equals("DiagramGridXHelp")
989 [ # # ][ # # ]: 0 : || aCommand.equals("DiagramGridYHelp")
990 [ # # ][ # # ]: 0 : || aCommand.equals("DiagramGridZHelp")
991 [ # # ][ # # ]: 0 : || aCommand.equals("DiagramGridAll")
992 : :
993 [ # # ][ # # ]: 0 : || aCommand.equals("DiagramWall")
994 [ # # ][ # # ]: 0 : || aCommand.equals("DiagramFloor")
995 [ # # ][ # # ]: 0 : || aCommand.equals("DiagramArea")
996 [ # # ][ # # ]: 0 : || aCommand.equals("Legend")
997 : :
998 [ # # ][ # # ]: 0 : || aCommand.equals("FormatWall")
999 [ # # ][ # # ]: 0 : || aCommand.equals("FormatFloor")
1000 [ # # ][ # # ]: 0 : || aCommand.equals("FormatChartArea")
1001 [ # # ][ # # ]: 0 : || aCommand.equals("FormatLegend")
1002 : :
1003 [ # # ][ # # ]: 0 : || aCommand.equals("FormatTitle")
1004 [ # # ][ # # ]: 0 : || aCommand.equals("FormatAxis")
1005 [ # # ][ # # ]: 0 : || aCommand.equals("FormatDataSeries")
1006 [ # # ][ # # ]: 0 : || aCommand.equals("FormatDataPoint")
1007 [ # # ][ # # ]: 0 : || aCommand.equals("FormatDataLabels")
1008 [ # # ][ # # ]: 0 : || aCommand.equals("FormatDataLabel")
1009 [ # # ][ # # ]: 0 : || aCommand.equals("FormatXErrorBars")
1010 [ # # ][ # # ]: 0 : || aCommand.equals("FormatYErrorBars")
1011 [ # # ][ # # ]: 0 : || aCommand.equals("FormatMeanValue")
1012 [ # # ][ # # ]: 0 : || aCommand.equals("FormatTrendline")
1013 [ # # ][ # # ]: 0 : || aCommand.equals("FormatTrendlineEquation")
1014 [ # # ][ # # ]: 0 : || aCommand.equals("FormatStockLoss")
1015 [ # # ][ # # ]: 0 : || aCommand.equals("FormatStockGain")
1016 [ # # ][ # # ]: 0 : || aCommand.equals("FormatMajorGrid")
1017 [ # # ][ # # ]: 0 : || aCommand.equals("FormatMinorGrid")
1018 : : )
1019 : 0 : return true;
1020 : :
1021 : : // else
1022 : 0 : return false;
1023 : : }
1024 : : } // anonymous namespace
1025 : :
1026 : 1538 : uno::Reference<frame::XDispatch> SAL_CALL ChartController
1027 : : ::queryDispatch( const util::URL& rURL
1028 : : , const rtl::OUString& rTargetFrameName
1029 : : , sal_Int32 /* nSearchFlags */)
1030 : : throw(uno::RuntimeException)
1031 : : {
1032 [ + - ][ + - ]: 1538 : if ( !m_aLifeTimeManager.impl_isDisposed() && getModel().is() )
[ + - ][ + - ]
[ + - ]
[ + - # # ]
1033 : : {
1034 [ + + ][ + - ]: 1538 : if( !rTargetFrameName.isEmpty() && rTargetFrameName == "_self" )
[ + + ]
1035 : 1504 : return m_aDispatchContainer.getDispatchForURL( rURL );
1036 : : }
1037 : 1538 : return uno::Reference< frame::XDispatch > ();
1038 : : }
1039 : :
1040 : 0 : uno::Sequence<uno::Reference<frame::XDispatch > > ChartController
1041 : : ::queryDispatches( const uno::Sequence<
1042 : : frame::DispatchDescriptor>& xDescripts)
1043 : : throw(uno::RuntimeException)
1044 : : {
1045 [ # # ]: 0 : if ( !m_aLifeTimeManager.impl_isDisposed() )
1046 : : {
1047 : 0 : return m_aDispatchContainer.getDispatchesForURLs( xDescripts );
1048 : : }
1049 : 0 : return uno::Sequence<uno::Reference<frame::XDispatch > > ();
1050 : : }
1051 : :
1052 : : //-----------------------------------------------------------------
1053 : : // frame::XDispatch
1054 : : //-----------------------------------------------------------------
1055 : :
1056 : 0 : void SAL_CALL ChartController
1057 : : ::dispatch( const util::URL& rURL
1058 : : , const uno::Sequence< beans::PropertyValue >& rArgs )
1059 : : throw (uno::RuntimeException)
1060 : : {
1061 : : //@todo avoid OString
1062 [ # # ]: 0 : rtl::OString aCommand( rtl::OUStringToOString( rURL.Path, RTL_TEXTENCODING_ASCII_US ) );
1063 : :
1064 [ # # ]: 0 : if(aCommand.equals("Paste"))
1065 [ # # ]: 0 : this->executeDispatch_Paste();
1066 [ # # ]: 0 : else if(aCommand.equals("Copy"))
1067 [ # # ]: 0 : this->executeDispatch_Copy();
1068 [ # # ]: 0 : else if(aCommand.equals("Cut"))
1069 [ # # ]: 0 : this->executeDispatch_Cut();
1070 [ # # ]: 0 : else if(aCommand.equals("DataRanges"))
1071 [ # # ]: 0 : this->executeDispatch_SourceData();
1072 : : //----------------------------------
1073 [ # # ]: 0 : else if(aCommand.equals("Update")) //Update Chart
1074 : : {
1075 [ # # ][ # # ]: 0 : ChartViewHelper::setViewToDirtyState( getModel() );
1076 [ # # ]: 0 : SolarMutexGuard aGuard;
1077 [ # # ]: 0 : if( m_pChartWindow )
1078 [ # # ][ # # ]: 0 : m_pChartWindow->Invalidate();
1079 : : }
1080 [ # # ]: 0 : else if(aCommand.equals("DiagramData"))
1081 [ # # ]: 0 : this->executeDispatch_EditData();
1082 : : //insert objects
1083 [ # # # # ]: 0 : else if( aCommand.equals("InsertTitles")
[ # # ][ # # ]
[ # # ]
1084 [ # # ][ # # ]: 0 : || aCommand.equals("InsertMenuTitles") )
1085 [ # # ]: 0 : this->executeDispatch_InsertTitles();
1086 [ # # ]: 0 : else if( aCommand.equals("InsertMenuLegend") )
1087 [ # # ]: 0 : this->executeDispatch_OpenLegendDialog();
1088 [ # # ]: 0 : else if( aCommand.equals("InsertLegend") )
1089 [ # # ]: 0 : this->executeDispatch_InsertLegend();
1090 [ # # ]: 0 : else if( aCommand.equals("DeleteLegend") )
1091 [ # # ]: 0 : this->executeDispatch_DeleteLegend();
1092 [ # # ]: 0 : else if( aCommand.equals("InsertMenuDataLabels"))
1093 [ # # ]: 0 : this->executeDispatch_InsertMenu_DataLabels();
1094 [ # # # # ]: 0 : else if( aCommand.equals("InsertMenuAxes")
[ # # ][ # # ]
[ # # ]
1095 [ # # ][ # # ]: 0 : || aCommand.equals("InsertRemoveAxes") )
1096 [ # # ]: 0 : this->executeDispatch_InsertAxes();
1097 [ # # ]: 0 : else if( aCommand.equals("InsertMenuGrids"))
1098 [ # # ]: 0 : this->executeDispatch_InsertGrid();
1099 [ # # ]: 0 : else if( aCommand.equals("InsertMenuTrendlines"))
1100 [ # # ]: 0 : this->executeDispatch_InsertMenu_Trendlines();
1101 [ # # ]: 0 : else if( aCommand.equals("InsertMenuMeanValues"))
1102 [ # # ]: 0 : this->executeDispatch_InsertMenu_MeanValues();
1103 [ # # ]: 0 : else if( aCommand.equals("InsertMenuXErrorBars"))
1104 [ # # ]: 0 : this->executeDispatch_InsertErrorBars(false);
1105 [ # # ]: 0 : else if( aCommand.equals("InsertMenuYErrorBars"))
1106 [ # # ]: 0 : this->executeDispatch_InsertErrorBars(true);
1107 [ # # ]: 0 : else if( aCommand.equals("InsertSymbol"))
1108 [ # # ]: 0 : this->executeDispatch_InsertSpecialCharacter();
1109 [ # # ]: 0 : else if( aCommand.equals("InsertTrendline"))
1110 [ # # ]: 0 : this->executeDispatch_InsertTrendline();
1111 [ # # ]: 0 : else if( aCommand.equals("DeleteTrendline"))
1112 [ # # ]: 0 : this->executeDispatch_DeleteTrendline();
1113 [ # # ]: 0 : else if( aCommand.equals("InsertMeanValue"))
1114 [ # # ]: 0 : this->executeDispatch_InsertMeanValue();
1115 [ # # ]: 0 : else if( aCommand.equals("DeleteMeanValue"))
1116 [ # # ]: 0 : this->executeDispatch_DeleteMeanValue();
1117 [ # # ]: 0 : else if( aCommand.equals("InsertXErrorBars"))
1118 [ # # ]: 0 : this->executeDispatch_InsertErrorBars(false);
1119 [ # # ]: 0 : else if( aCommand.equals("InsertYErrorBars"))
1120 [ # # ]: 0 : this->executeDispatch_InsertErrorBars(true);
1121 [ # # ]: 0 : else if( aCommand.equals("DeleteXErrorBars"))
1122 [ # # ]: 0 : this->executeDispatch_DeleteErrorBars(false);
1123 [ # # ]: 0 : else if( aCommand.equals("DeleteYErrorBars"))
1124 [ # # ]: 0 : this->executeDispatch_DeleteErrorBars(true);
1125 [ # # ]: 0 : else if( aCommand.equals("InsertTrendlineEquation"))
1126 [ # # ]: 0 : this->executeDispatch_InsertTrendlineEquation();
1127 [ # # ]: 0 : else if( aCommand.equals("DeleteTrendlineEquation"))
1128 [ # # ]: 0 : this->executeDispatch_DeleteTrendlineEquation();
1129 [ # # ]: 0 : else if( aCommand.equals("InsertTrendlineEquationAndR2"))
1130 [ # # ]: 0 : this->executeDispatch_InsertTrendlineEquation( true );
1131 [ # # ]: 0 : else if( aCommand.equals("InsertR2Value"))
1132 [ # # ]: 0 : this->executeDispatch_InsertR2Value();
1133 [ # # ]: 0 : else if( aCommand.equals("DeleteR2Value"))
1134 [ # # ]: 0 : this->executeDispatch_DeleteR2Value();
1135 [ # # ]: 0 : else if( aCommand.equals("InsertDataLabels") )
1136 [ # # ]: 0 : this->executeDispatch_InsertDataLabels();
1137 [ # # ]: 0 : else if( aCommand.equals("InsertDataLabel") )
1138 [ # # ]: 0 : this->executeDispatch_InsertDataLabel();
1139 [ # # ]: 0 : else if( aCommand.equals("DeleteDataLabels") )
1140 [ # # ]: 0 : this->executeDispatch_DeleteDataLabels();
1141 [ # # ]: 0 : else if( aCommand.equals("DeleteDataLabel") )
1142 [ # # ]: 0 : this->executeDispatch_DeleteDataLabel();
1143 [ # # ]: 0 : else if( aCommand.equals("ResetAllDataPoints") )
1144 [ # # ]: 0 : this->executeDispatch_ResetAllDataPoints();
1145 [ # # ]: 0 : else if( aCommand.equals("ResetDataPoint") )
1146 [ # # ]: 0 : this->executeDispatch_ResetDataPoint();
1147 [ # # ]: 0 : else if( aCommand.equals("InsertAxis") )
1148 [ # # ]: 0 : this->executeDispatch_InsertAxis();
1149 [ # # ]: 0 : else if( aCommand.equals("InsertMajorGrid") )
1150 [ # # ]: 0 : this->executeDispatch_InsertMajorGrid();
1151 [ # # ]: 0 : else if( aCommand.equals("InsertMinorGrid") )
1152 [ # # ]: 0 : this->executeDispatch_InsertMinorGrid();
1153 [ # # ]: 0 : else if( aCommand.equals("InsertAxisTitle") )
1154 [ # # ]: 0 : this->executeDispatch_InsertAxisTitle();
1155 [ # # ]: 0 : else if( aCommand.equals("DeleteAxis") )
1156 [ # # ]: 0 : this->executeDispatch_DeleteAxis();
1157 [ # # ]: 0 : else if( aCommand.equals("DeleteMajorGrid") )
1158 [ # # ]: 0 : this->executeDispatch_DeleteMajorGrid();
1159 [ # # ]: 0 : else if( aCommand.equals("DeleteMinorGrid") )
1160 [ # # ]: 0 : this->executeDispatch_DeleteMinorGrid();
1161 : : //format objects
1162 [ # # ]: 0 : else if( aCommand.equals("FormatSelection") )
1163 [ # # ]: 0 : this->executeDispatch_ObjectProperties();
1164 [ # # ]: 0 : else if( aCommand.equals("TransformDialog"))
1165 : : {
1166 [ # # ][ # # ]: 0 : if ( isShapeContext() )
1167 : : {
1168 [ # # ]: 0 : this->impl_ShapeControllerDispatch( rURL, rArgs );
1169 : : }
1170 : : else
1171 : : {
1172 [ # # ]: 0 : this->executeDispatch_PositionAndSize();
1173 : : }
1174 : : }
1175 [ # # ][ # # ]: 0 : else if( lcl_isFormatObjectCommand(aCommand) )
1176 [ # # ]: 0 : this->executeDispatch_FormatObject(rURL.Path);
1177 : : //more format
1178 [ # # ]: 0 : else if( aCommand.equals("DiagramType"))
1179 [ # # ]: 0 : this->executeDispatch_ChartType();
1180 [ # # ]: 0 : else if( aCommand.equals("View3D"))
1181 [ # # ]: 0 : this->executeDispatch_View3D();
1182 [ # # ]: 0 : else if ( aCommand.equals( "Forward" ) )
1183 : : {
1184 [ # # ][ # # ]: 0 : if ( isShapeContext() )
1185 : : {
1186 [ # # ]: 0 : this->impl_ShapeControllerDispatch( rURL, rArgs );
1187 : : }
1188 : : else
1189 : : {
1190 [ # # ]: 0 : this->executeDispatch_MoveSeries( sal_True );
1191 : : }
1192 : : }
1193 [ # # ]: 0 : else if ( aCommand.equals( "Backward" ) )
1194 : : {
1195 [ # # ][ # # ]: 0 : if ( isShapeContext() )
1196 : : {
1197 [ # # ]: 0 : this->impl_ShapeControllerDispatch( rURL, rArgs );
1198 : : }
1199 : : else
1200 : : {
1201 [ # # ]: 0 : this->executeDispatch_MoveSeries( sal_False );
1202 : : }
1203 : : }
1204 [ # # ]: 0 : else if( aCommand.equals("NewArrangement"))
1205 [ # # ]: 0 : this->executeDispatch_NewArrangement();
1206 [ # # ]: 0 : else if( aCommand.equals("ToggleLegend"))
1207 [ # # ]: 0 : this->executeDispatch_ToggleLegend();
1208 [ # # ]: 0 : else if( aCommand.equals("ToggleGridHorizontal"))
1209 [ # # ]: 0 : this->executeDispatch_ToggleGridHorizontal();
1210 [ # # ]: 0 : else if( aCommand.equals("ScaleText"))
1211 [ # # ]: 0 : this->executeDispatch_ScaleText();
1212 [ # # ]: 0 : else if( aCommand.equals("StatusBarVisible"))
1213 : : {
1214 : : // workaround: this should not be necessary.
1215 [ # # ]: 0 : uno::Reference< beans::XPropertySet > xPropSet( m_xFrame, uno::UNO_QUERY );
1216 [ # # ]: 0 : if( xPropSet.is() )
1217 : : {
1218 : 0 : uno::Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
1219 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue( C2U( "LayoutManager" ) ) >>= xLayoutManager;
[ # # ][ # # ]
1220 [ # # ]: 0 : if ( xLayoutManager.is() )
1221 : : {
1222 [ # # ][ # # ]: 0 : bool bIsVisible( xLayoutManager->isElementVisible( C2U("private:resource/statusbar/statusbar")));
[ # # ]
1223 [ # # ]: 0 : if( bIsVisible )
1224 : : {
1225 [ # # ][ # # ]: 0 : xLayoutManager->hideElement( C2U( "private:resource/statusbar/statusbar"));
[ # # ]
1226 [ # # ][ # # ]: 0 : xLayoutManager->destroyElement( C2U( "private:resource/statusbar/statusbar"));
[ # # ]
1227 : : }
1228 : : else
1229 : : {
1230 [ # # ][ # # ]: 0 : xLayoutManager->createElement( C2U( "private:resource/statusbar/statusbar"));
[ # # ]
1231 [ # # ][ # # ]: 0 : xLayoutManager->showElement( C2U( "private:resource/statusbar/statusbar"));
[ # # ]
1232 : : }
1233 : : // @todo: update menu state (checkmark next to "Statusbar").
1234 : 0 : }
1235 : 0 : }
1236 : 0 : }
1237 : 0 : }
1238 : :
1239 : 0 : void SAL_CALL ChartController
1240 : : ::addStatusListener( const uno::Reference<frame::XStatusListener >& /* xControl */
1241 : : , const util::URL& /* aURL */ )
1242 : : throw (uno::RuntimeException)
1243 : : {
1244 : : //@todo
1245 : 0 : }
1246 : :
1247 : 0 : void SAL_CALL ChartController
1248 : : ::removeStatusListener( const uno::Reference<frame::XStatusListener >& /* xControl */
1249 : : , const util::URL& /* aURL */ )
1250 : : throw (uno::RuntimeException)
1251 : : {
1252 : : //@todo
1253 : 0 : }
1254 : :
1255 : : //-----------------------------------------------------------------
1256 : : // XContextMenuInterception (optional interface)
1257 : : //-----------------------------------------------------------------
1258 : 0 : void SAL_CALL ChartController
1259 : : ::registerContextMenuInterceptor( const uno::Reference<
1260 : : ui::XContextMenuInterceptor > & /* xInterceptor */)
1261 : : throw(uno::RuntimeException)
1262 : : {
1263 : : //@todo
1264 : 0 : }
1265 : :
1266 : 0 : void SAL_CALL ChartController
1267 : : ::releaseContextMenuInterceptor( const uno::Reference<
1268 : : ui::XContextMenuInterceptor > & /* xInterceptor */)
1269 : : throw(uno::RuntimeException)
1270 : : {
1271 : : //@todo
1272 : 0 : }
1273 : :
1274 : : // ____ XEmbeddedClient ____
1275 : : // implementation see: ChartController_EditData.cxx
1276 : :
1277 : : //-----------------------------------------------------------------------------
1278 : : //-----------------------------------------------------------------------------
1279 : : //-----------------------------------------------------------------------------
1280 : :
1281 : 0 : void SAL_CALL ChartController::executeDispatch_ChartType()
1282 : : {
1283 : : // using assignment for broken gcc 3.3
1284 : : UndoLiveUpdateGuard aUndoGuard = UndoLiveUpdateGuard(
1285 [ # # ][ # # ]: 0 : String( SchResId( STR_ACTION_EDIT_CHARTTYPE )), m_xUndoManager );
[ # # ][ # # ]
[ # # ]
1286 : :
1287 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
1288 : : //prepare and open dialog
1289 [ # # ][ # # ]: 0 : ChartTypeDialog aDlg( m_pChartWindow, getModel(), m_xCC );
1290 [ # # ][ # # ]: 0 : if( aDlg.Execute() == RET_OK )
1291 : : {
1292 [ # # ]: 0 : impl_adaptDataSeriesAutoResize();
1293 [ # # ]: 0 : aUndoGuard.commit();
1294 [ # # ][ # # ]: 0 : }
[ # # ]
1295 : 0 : }
1296 : :
1297 : 0 : void SAL_CALL ChartController::executeDispatch_SourceData()
1298 : : {
1299 : : //-------------------------------------------------------------
1300 : : //convert properties to ItemSet
1301 [ # # ][ # # ]: 0 : uno::Reference< XChartDocument > xChartDoc( getModel(), uno::UNO_QUERY );
1302 : : OSL_ENSURE( xChartDoc.is(), "Invalid XChartDocument" );
1303 [ # # ]: 0 : if( !xChartDoc.is())
1304 : 0 : return;
1305 : :
1306 : : // using assignment for broken gcc 3.3
1307 : : UndoLiveUpdateGuard aUndoGuard = UndoLiveUpdateGuard(
1308 [ # # ][ # # ]: 0 : String( SchResId( STR_ACTION_EDIT_DATA_RANGES )), m_xUndoManager );
[ # # ][ # # ]
[ # # ]
1309 [ # # ]: 0 : if( xChartDoc.is())
1310 : : {
1311 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
1312 [ # # ]: 0 : ::chart::DataSourceDialog aDlg( m_pChartWindow, xChartDoc, m_xCC );
1313 [ # # ][ # # ]: 0 : if( aDlg.Execute() == RET_OK )
1314 : : {
1315 [ # # ]: 0 : impl_adaptDataSeriesAutoResize();
1316 [ # # ]: 0 : aUndoGuard.commit();
1317 [ # # ][ # # ]: 0 : }
1318 [ # # ][ # # ]: 0 : }
1319 : : }
1320 : :
1321 : 0 : void SAL_CALL ChartController::executeDispatch_MoveSeries( sal_Bool bForward )
1322 : : {
1323 [ # # ][ # # ]: 0 : ControllerLockGuard aCLGuard( getModel() );
1324 : :
1325 : : //get selected series
1326 [ # # ]: 0 : ::rtl::OUString aObjectCID(m_aSelection.getSelectedCID());
1327 : : uno::Reference< XDataSeries > xGivenDataSeries( ObjectIdentifier::getDataSeriesForCID( //yyy todo also legendentries and labels?
1328 [ # # ][ # # ]: 0 : aObjectCID, getModel() ) );
1329 : :
1330 : : UndoGuardWithSelection aUndoGuard(
1331 : : ActionDescriptionProvider::createDescription(
1332 : : (bForward ? ActionDescriptionProvider::MOVE_TOTOP : ActionDescriptionProvider::MOVE_TOBOTTOM),
1333 : : String( SchResId( STR_OBJECT_DATASERIES ))),
1334 [ # # ][ # # ]: 0 : m_xUndoManager );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1335 : :
1336 [ # # ][ # # ]: 0 : bool bChanged = DiagramHelper::moveSeries( ChartModelHelper::findDiagram( getModel() ), xGivenDataSeries, bForward );
[ # # ]
1337 [ # # ]: 0 : if( bChanged )
1338 : : {
1339 [ # # ][ # # ]: 0 : m_aSelection.setSelection( ObjectIdentifier::getMovedSeriesCID( aObjectCID, bForward ) );
1340 [ # # ]: 0 : aUndoGuard.commit();
1341 [ # # ][ # # ]: 0 : }
1342 : 0 : }
1343 : :
1344 : : // ____ XMultiServiceFactory ____
1345 : : uno::Reference< uno::XInterface > SAL_CALL
1346 : 0 : ChartController::createInstance( const ::rtl::OUString& aServiceSpecifier )
1347 : : throw (uno::Exception,
1348 : : uno::RuntimeException)
1349 : : {
1350 : 0 : uno::Reference< uno::XInterface > xResult;
1351 : :
1352 [ # # ][ # # ]: 0 : if( aServiceSpecifier.equals( CHART_ACCESSIBLE_TEXT_SERVICE_NAME ))
1353 [ # # ][ # # ]: 0 : xResult.set( impl_createAccessibleTextContext());
1354 : 0 : return xResult;
1355 : : }
1356 : :
1357 : : uno::Reference< uno::XInterface > SAL_CALL
1358 : 0 : ChartController::createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier,
1359 : : const uno::Sequence< uno::Any >& /* Arguments */ )
1360 : : throw (uno::Exception,
1361 : : uno::RuntimeException)
1362 : : {
1363 : : // ignore Arguments
1364 : 0 : return createInstance( ServiceSpecifier );
1365 : : }
1366 : :
1367 : : uno::Sequence< ::rtl::OUString > SAL_CALL
1368 : 0 : ChartController::getAvailableServiceNames()
1369 : : throw (uno::RuntimeException)
1370 : : {
1371 : 0 : uno::Sequence< ::rtl::OUString > aServiceNames(1);
1372 [ # # ][ # # ]: 0 : aServiceNames[0] = CHART_ACCESSIBLE_TEXT_SERVICE_NAME;
1373 : 0 : return aServiceNames;
1374 : : }
1375 : :
1376 : : // ____ XModifyListener ____
1377 : 1544 : void SAL_CALL ChartController::modified( const lang::EventObject& /* aEvent */ )
1378 : : throw (uno::RuntimeException)
1379 : : {
1380 : : // the source can also be a subobject of the ChartModel
1381 : : // @todo: change the source in ChartModel to always be the model itself ?
1382 : : //todo? update menu states ?
1383 : 1544 : }
1384 : :
1385 : : //-----------------------------------------------------------------------------
1386 : :
1387 : 0 : IMPL_LINK( ChartController, NotifyUndoActionHdl, SdrUndoAction*, pUndoAction )
1388 : : {
1389 [ # # ]: 0 : ENSURE_OR_RETURN( pUndoAction, "invalid Undo action", 1L );
1390 : :
1391 [ # # ]: 0 : ::rtl::OUString aObjectCID = m_aSelection.getSelectedCID();
1392 [ # # ]: 0 : if ( aObjectCID.isEmpty() )
1393 : : {
1394 : : try
1395 : : {
1396 [ # # ][ # # ]: 0 : const Reference< document::XUndoManagerSupplier > xSuppUndo( getModel(), uno::UNO_QUERY_THROW );
1397 [ # # ][ # # ]: 0 : const Reference< document::XUndoManager > xUndoManager( xSuppUndo->getUndoManager(), uno::UNO_QUERY_THROW );
[ # # ]
1398 [ # # ][ # # ]: 0 : const Reference< document::XUndoAction > xAction( new impl::ShapeUndoElement( *pUndoAction ) );
[ # # ]
1399 [ # # ][ # # ]: 0 : xUndoManager->addUndoAction( xAction );
[ # # ]
1400 : : }
1401 [ # # ]: 0 : catch( const uno::Exception& )
1402 : : {
1403 : : DBG_UNHANDLED_EXCEPTION();
1404 : : }
1405 : : }
1406 : 0 : return 0L;
1407 : : }
1408 : :
1409 : 783 : DrawModelWrapper* ChartController::GetDrawModelWrapper()
1410 : : {
1411 [ + + ]: 783 : if( !m_pDrawModelWrapper.get() )
1412 : : {
1413 : 34 : ExplicitValueProvider* pProvider = ExplicitValueProvider::getExplicitValueProvider( m_xChartView );
1414 [ + - ]: 34 : if( pProvider )
1415 [ + - ]: 34 : m_pDrawModelWrapper = pProvider->getDrawModelWrapper();
1416 [ + - ]: 34 : if ( m_pDrawModelWrapper.get() )
1417 : : {
1418 [ + - ]: 34 : m_pDrawModelWrapper->getSdrModel().SetNotifyUndoActionHdl( LINK( this, ChartController, NotifyUndoActionHdl ) );
1419 : : }
1420 : : }
1421 : 783 : return m_pDrawModelWrapper.get();
1422 : : }
1423 : :
1424 : 0 : DrawViewWrapper* ChartController::GetDrawViewWrapper()
1425 : : {
1426 [ # # ]: 0 : if ( !m_pDrawViewWrapper )
1427 : : {
1428 : 0 : impl_createDrawViewController();
1429 : : }
1430 : 0 : return m_pDrawViewWrapper;
1431 : : }
1432 : :
1433 : 0 : uno::Reference< XAccessible > ChartController::CreateAccessible()
1434 : : {
1435 [ # # ][ # # ]: 0 : uno::Reference< XAccessible > xResult = new AccessibleChartView( m_xCC, GetDrawViewWrapper() );
[ # # ]
1436 [ # # ][ # # ]: 0 : impl_initializeAccessible( uno::Reference< lang::XInitialization >( xResult, uno::UNO_QUERY ) );
1437 : 0 : return xResult;
1438 : : }
1439 : :
1440 : 829 : void ChartController::impl_invalidateAccessible()
1441 : : {
1442 [ + - ]: 829 : SolarMutexGuard aGuard;
1443 [ + + ]: 829 : if( m_pChartWindow )
1444 : : {
1445 [ + - ][ + - ]: 795 : Reference< lang::XInitialization > xInit( m_pChartWindow->GetAccessible(false), uno::UNO_QUERY );
1446 [ - + ]: 795 : if(xInit.is())
1447 : : {
1448 [ # # ]: 0 : uno::Sequence< uno::Any > aArguments(3);//empty arguments -> invalid accessible
1449 [ # # ][ # # ]: 0 : xInit->initialize(aArguments);
[ # # ]
1450 : 795 : }
1451 [ + - ]: 829 : }
1452 : 829 : }
1453 : 749 : void ChartController::impl_initializeAccessible()
1454 : : {
1455 [ + - ]: 749 : SolarMutexGuard aGuard;
1456 [ + - ]: 749 : if( m_pChartWindow )
1457 [ + - ][ + - ]: 749 : this->impl_initializeAccessible( Reference< lang::XInitialization >( m_pChartWindow->GetAccessible(false), uno::UNO_QUERY ) );
[ + - ][ + - ]
1458 : 749 : }
1459 : 749 : void ChartController::impl_initializeAccessible( const uno::Reference< lang::XInitialization >& xInit )
1460 : : {
1461 [ - + ]: 749 : if(xInit.is())
1462 : : {
1463 [ # # ]: 0 : uno::Sequence< uno::Any > aArguments(5);
1464 [ # # ]: 0 : uno::Reference<view::XSelectionSupplier> xSelectionSupplier(this);
1465 [ # # ][ # # ]: 0 : aArguments[0]=uno::makeAny(xSelectionSupplier);
1466 [ # # ]: 0 : uno::Reference<frame::XModel> xModel(getModel());
1467 [ # # ][ # # ]: 0 : aArguments[1]=uno::makeAny(xModel);
1468 [ # # ][ # # ]: 0 : aArguments[2]=uno::makeAny(m_xChartView);
1469 : 0 : uno::Reference< XAccessible > xParent;
1470 : : {
1471 [ # # ]: 0 : SolarMutexGuard aGuard;
1472 [ # # ]: 0 : if( m_pChartWindow )
1473 : : {
1474 [ # # ]: 0 : Window* pParentWin( m_pChartWindow->GetAccessibleParentWindow());
1475 [ # # ]: 0 : if( pParentWin )
1476 [ # # ][ # # ]: 0 : xParent.set( pParentWin->GetAccessible());
1477 [ # # ]: 0 : }
1478 : : }
1479 [ # # ][ # # ]: 0 : aArguments[3]=uno::makeAny(xParent);
1480 [ # # ][ # # ]: 0 : aArguments[4]=uno::makeAny(m_xViewWindow);
1481 : :
1482 [ # # ][ # # ]: 0 : xInit->initialize(aArguments);
[ # # ]
1483 : : }
1484 : 749 : }
1485 : :
1486 : 34 : ::std::set< ::rtl::OUString > ChartController::impl_getAvailableCommands()
1487 : : {
1488 : : return ::comphelper::MakeSet< ::rtl::OUString >
1489 : : // commands for container forward
1490 [ + - ][ + - ]: 68 : ( "AddDirect" ) ( "NewDoc" ) ( "Open" )
[ + - ]
1491 [ + - ][ + - ]: 102 : ( "Save" ) ( "SaveAs" ) ( "SendMail" )
[ + - ]
1492 [ + - ][ + - ]: 102 : ( "EditDoc" ) ( "ExportDirectToPDF" ) ( "PrintDefault" )
[ + - ]
1493 : :
1494 : : // own commands
1495 [ + - ][ + - ]: 102 : ( "Cut" ) ( "Copy" ) ( "Paste" )
[ + - ]
1496 [ + - ][ + - ]: 102 : ( "DataRanges" ) ( "DiagramData" )
1497 : : // insert objects
1498 [ + - ][ + - ]: 102 : ( "InsertMenuTitles" ) ( "InsertTitles" )
1499 [ + - ][ + - ]: 102 : ( "InsertMenuLegend" ) ( "InsertLegend" ) ( "DeleteLegend" )
[ + - ]
1500 [ + - ]: 102 : ( "InsertMenuDataLabels" )
1501 [ + - ][ + - ]: 102 : ( "InsertMenuAxes" ) ( "InsertRemoveAxes" ) ( "InsertMenuGrids" )
[ + - ]
1502 [ + - ]: 102 : ( "InsertSymbol" )
1503 [ + - ][ + - ]: 102 : ( "InsertTrendlineEquation" ) ( "InsertTrendlineEquationAndR2" )
1504 [ + - ][ + - ]: 102 : ( "InsertR2Value" ) ( "DeleteR2Value" )
1505 [ + - ][ + - ]: 102 : ( "InsertMenuTrendlines" ) ( "InsertTrendline" )
1506 [ + - ][ + - ]: 102 : ( "InsertMenuMeanValues" ) ( "InsertMeanValue" )
1507 [ + - ][ + - ]: 102 : ( "InsertMenuXErrorBars" ) ( "InsertXErrorBars" )
1508 [ + - ][ + - ]: 102 : ( "InsertMenuYErrorBars" ) ( "InsertYErrorBars" )
1509 [ + - ][ + - ]: 102 : ( "InsertDataLabels" ) ( "InsertDataLabel" )
1510 [ + - ][ + - ]: 102 : ( "DeleteTrendline" ) ( "DeleteMeanValue" ) ( "DeleteTrendlineEquation" )
[ + - ]
1511 [ + - ][ + - ]: 102 : ( "DeleteXErrorBars" ) ( "DeleteYErrorBars" )
1512 [ + - ][ + - ]: 102 : ( "DeleteDataLabels" ) ( "DeleteDataLabel" )
1513 : : //format objects
1514 [ + - ][ + - ]: 102 : ( "FormatSelection" ) ( "TransformDialog" )
1515 [ + - ][ + - ]: 102 : ( "DiagramType" ) ( "View3D" )
1516 [ + - ][ + - ]: 102 : ( "Forward" ) ( "Backward" )
1517 [ + - ][ + - ]: 102 : ( "MainTitle" ) ( "SubTitle" )
1518 [ + - ][ + - ]: 102 : ( "XTitle" ) ( "YTitle" ) ( "ZTitle" )
[ + - ]
1519 [ + - ][ + - ]: 102 : ( "SecondaryXTitle" ) ( "SecondaryYTitle" )
1520 [ + - ][ + - ]: 102 : ( "AllTitles" ) ( "Legend" )
1521 [ + - ][ + - ]: 102 : ( "DiagramAxisX" ) ( "DiagramAxisY" ) ( "DiagramAxisZ" )
[ + - ]
1522 [ + - ][ + - ]: 102 : ( "DiagramAxisA" ) ( "DiagramAxisB" ) ( "DiagramAxisAll" )
[ + - ]
1523 [ + - ][ + - ]: 102 : ( "DiagramGridXMain" ) ( "DiagramGridYMain" ) ( "DiagramGridZMain" )
[ + - ]
1524 [ + - ][ + - ]: 102 : ( "DiagramGridXHelp" ) ( "DiagramGridYHelp" ) ( "DiagramGridZHelp" )
[ + - ]
1525 [ + - ]: 102 : ( "DiagramGridAll" )
1526 [ + - ][ + - ]: 102 : ( "DiagramWall" ) ( "DiagramFloor" ) ( "DiagramArea" )
[ + - ]
1527 : :
1528 : : //context menu - format objects entries
1529 [ + - ][ + - ]: 102 : ( "FormatWall" ) ( "FormatFloor" ) ( "FormatChartArea" )
[ + - ]
1530 [ + - ]: 102 : ( "FormatLegend" )
1531 : :
1532 [ + - ][ + - ]: 102 : ( "FormatAxis" ) ( "FormatTitle" )
1533 [ + - ][ + - ]: 102 : ( "FormatDataSeries" ) ( "FormatDataPoint" )
1534 [ + - ][ + - ]: 102 : ( "ResetAllDataPoints" ) ( "ResetDataPoint" )
1535 [ + - ][ + - ]: 102 : ( "FormatDataLabels" ) ( "FormatDataLabel" )
1536 [ + - ][ + - ]: 102 : ( "FormatMeanValue" ) ( "FormatTrendline" ) ( "FormatTrendlineEquation" )
[ + - ]
1537 [ + - ][ + - ]: 102 : ( "FormatXErrorBars" ) ( "FormatYErrorBars" )
1538 [ + - ][ + - ]: 102 : ( "FormatStockLoss" ) ( "FormatStockGain" )
1539 : :
1540 [ + - ][ + - ]: 102 : ( "FormatMajorGrid" ) ( "InsertMajorGrid" ) ( "DeleteMajorGrid" )
[ + - ]
1541 [ + - ][ + - ]: 102 : ( "FormatMinorGrid" ) ( "InsertMinorGrid" ) ( "DeleteMinorGrid" )
[ + - ]
1542 [ + - ][ + - ]: 102 : ( "InsertAxis" ) ( "DeleteAxis" ) ( "InsertAxisTitle" )
[ + - ]
1543 : :
1544 : : // toolbar commands
1545 [ + - ][ + - ]: 102 : ( "ToggleGridHorizontal" )( "ToggleLegend" ) ( "ScaleText" )
[ + - ]
1546 [ + - ][ + - ]: 102 : ( "NewArrangement" ) ( "Update" )
1547 [ + - ][ + - ]: 102 : ( "DefaultColors" ) ( "BarWidth" ) ( "NumberOfLines" )
[ + - ]
1548 [ + - ]: 102 : ( "ArrangeRow" )
1549 [ + - ]: 102 : ( "StatusBarVisible" )
1550 [ + - ][ + - ]: 102 : ( "ChartElementSelector" )
1551 : : ;
1552 : : }
1553 : :
1554 : : //.............................................................................
1555 : : } //namespace chart
1556 : : //.............................................................................
1557 : :
1558 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|