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 : : #ifndef _CHART_CONTROLLER_HXX
20 : : #define _CHART_CONTROLLER_HXX
21 : :
22 : : #include "LifeTime.hxx"
23 : : #include "ServiceMacros.hxx"
24 : : #include "CommandDispatchContainer.hxx"
25 : : #include "SelectionHelper.hxx"
26 : :
27 : : // header for enum SdrDragMode
28 : : #include <svx/svdtypes.hxx>
29 : : // header for class Timer
30 : : #include <vcl/timer.hxx>
31 : : // header for class MouseEvent
32 : : #include <vcl/event.hxx>
33 : :
34 : : #include <cppuhelper/implbase12.hxx>
35 : :
36 : : #include <com/sun/star/accessibility/XAccessible.hpp>
37 : : #include <com/sun/star/document/XUndoManager.hpp>
38 : : #include <com/sun/star/frame/XController.hpp>
39 : : #include <com/sun/star/frame/XDispatchProvider.hpp>
40 : : #include <com/sun/star/frame/XDispatch.hpp>
41 : : #include <com/sun/star/view/XSelectionSupplier.hpp>
42 : : #include <com/sun/star/ui/XContextMenuInterception.hpp>
43 : : #include <com/sun/star/uno/XWeak.hpp>
44 : : #include <com/sun/star/util/XCloseListener.hpp>
45 : : #include <com/sun/star/util/XCloseable.hpp>
46 : : #include <com/sun/star/lang/XInitialization.hpp>
47 : : #include <com/sun/star/lang/XServiceInfo.hpp>
48 : : #include <com/sun/star/uno/XComponentContext.hpp>
49 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
50 : : #include <com/sun/star/util/XModifyListener.hpp>
51 : : #include <com/sun/star/util/XModeChangeListener.hpp>
52 : : #include <com/sun/star/awt/Point.hpp>
53 : : #include <com/sun/star/awt/Size.hpp>
54 : : #include <com/sun/star/util/XURLTransformer.hpp>
55 : : #include <com/sun/star/frame/XLayoutManagerListener.hpp>
56 : : #include <com/sun/star/frame/XLayoutManagerEventBroadcaster.hpp>
57 : :
58 : : #include <memory>
59 : : #include <boost/shared_ptr.hpp>
60 : : #include <set>
61 : :
62 : :
63 : : class SdrModel;
64 : :
65 : : namespace svt
66 : : {
67 : : class AcceleratorExecute;
68 : : }
69 : :
70 : : class DropTargetHelper;
71 : :
72 : : namespace com { namespace sun { namespace star {
73 : : namespace graphic {
74 : : class XGraphic;
75 : : }
76 : : }}}
77 : :
78 : :
79 : : //.............................................................................
80 : : namespace chart
81 : : {
82 : : //.............................................................................
83 : :
84 : : class UndoGuard;
85 : :
86 : : enum ChartDrawMode { CHARTDRAW_INSERT, CHARTDRAW_SELECT };
87 : :
88 : 34 : class WindowController
89 : : {
90 : : public:
91 [ - + ]: 34 : virtual ~WindowController() {};
92 : :
93 : : virtual void PrePaint()=0;
94 : : virtual void execute_Paint( const Rectangle& rRect )=0;
95 : : virtual void execute_MouseButtonDown( const MouseEvent& rMEvt )=0;
96 : : virtual void execute_MouseMove( const MouseEvent& rMEvt )=0;
97 : : virtual void execute_Tracking( const TrackingEvent& rTEvt )=0;
98 : : virtual void execute_MouseButtonUp( const MouseEvent& rMEvt )=0;
99 : : virtual void execute_Resize()=0;
100 : : virtual void execute_Activate()=0;
101 : : virtual void execute_Deactivate()=0;
102 : : virtual void execute_GetFocus()=0;
103 : : virtual void execute_LoseFocus()=0;
104 : : virtual void execute_Command( const CommandEvent& rCEvt )=0;
105 : : virtual bool execute_KeyInput( const KeyEvent& rKEvt )=0;
106 : :
107 : : /** get help text to be shown in a quick help
108 : :
109 : : @param aAtLogicPosition the position in logic coordinates (of the
110 : : window) of the mouse cursor to determine for
111 : : which object help is requested.
112 : :
113 : : @param bIsBalloonHelp determines whether to return the long text version
114 : : (balloon help) or the shorter one (quick help).
115 : :
116 : : @param rOutQuickHelpText is filled with the quick help text
117 : :
118 : : @param rOutEqualRect is filled with a rectangle that denotes the region
119 : : in which the quick help does not change.
120 : :
121 : : @return </sal_True>, if a quick help should be shown.
122 : : */
123 : : virtual bool requestQuickHelp(
124 : : ::Point aAtLogicPosition, bool bIsBalloonHelp,
125 : : ::rtl::OUString & rOutQuickHelpText, ::com::sun::star::awt::Rectangle & rOutEqualRect ) = 0;
126 : :
127 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() = 0;
128 : : };
129 : :
130 : : class ChartWindow;
131 : : class DrawModelWrapper;
132 : : class DrawViewWrapper;
133 : : class ReferenceSizeProvider;
134 : :
135 : : class ChartController : public ::cppu::WeakImplHelper12 <
136 : : ::com::sun::star::frame::XController //comprehends XComponent (required interface)
137 : : ,::com::sun::star::frame::XDispatchProvider //(required interface)
138 : : ,::com::sun::star::view::XSelectionSupplier //(optional interface)
139 : : ,::com::sun::star::ui::XContextMenuInterception //(optional interface)
140 : : ,::com::sun::star::util::XCloseListener //(needed for communication with XModel)
141 : : ,::com::sun::star::lang::XServiceInfo
142 : : // ,public ::com::sun::star::uno::XWeak // implemented by WeakImplHelper(optional interface)
143 : : // ,public ::com::sun::star::uno::XInterface // implemented by WeakImplHelper(optional interface)
144 : : // ,public ::com::sun::star::lang::XTypeProvider // implemented by WeakImplHelper
145 : : ,::com::sun::star::frame::XDispatch
146 : : ,::com::sun::star::awt::XWindow //this is the Window Controller part of this Controller, that will be given to a Frame via setComponent
147 : : ,::com::sun::star::lang::XMultiServiceFactory
148 : : ,::com::sun::star::util::XModifyListener
149 : : ,::com::sun::star::util::XModeChangeListener
150 : : ,::com::sun::star::frame::XLayoutManagerListener
151 : : >
152 : : , public WindowController
153 : : {
154 : : friend class DrawCommandDispatch;
155 : : friend class ShapeController;
156 : :
157 : : public:
158 : : //no default constructor
159 : : ChartController(::com::sun::star::uno::Reference<
160 : : ::com::sun::star::uno::XComponentContext > const & xContext);
161 : : virtual ~ChartController();
162 : :
163 : : //-----------------------------------------------------------------
164 : : // ::com::sun::star::lang::XServiceInfo
165 : : //-----------------------------------------------------------------
166 : :
167 : : APPHELPER_XSERVICEINFO_DECL()
168 [ + - ]: 34 : APPHELPER_SERVICE_FACTORY_HELPER(ChartController)
169 : :
170 : : //-----------------------------------------------------------------
171 : : // ::com::sun::star::frame::XController (required interface)
172 : : //-----------------------------------------------------------------
173 : : virtual void SAL_CALL
174 : : attachFrame( const ::com::sun::star::uno::Reference<
175 : : ::com::sun::star::frame::XFrame > & xFrame )
176 : : throw (::com::sun::star::uno::RuntimeException);
177 : :
178 : : virtual sal_Bool SAL_CALL
179 : : attachModel( const ::com::sun::star::uno::Reference<
180 : : ::com::sun::star::frame::XModel > & xModel )
181 : : throw (::com::sun::star::uno::RuntimeException);
182 : :
183 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > SAL_CALL
184 : : getFrame() throw (::com::sun::star::uno::RuntimeException);
185 : :
186 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > SAL_CALL
187 : : getModel() throw (::com::sun::star::uno::RuntimeException);
188 : :
189 : : virtual ::com::sun::star::uno::Any SAL_CALL
190 : : getViewData() throw (::com::sun::star::uno::RuntimeException);
191 : :
192 : : virtual void SAL_CALL
193 : : restoreViewData( const ::com::sun::star::uno::Any& rValue )
194 : : throw (::com::sun::star::uno::RuntimeException);
195 : :
196 : : virtual sal_Bool SAL_CALL
197 : : suspend( sal_Bool bSuspend )
198 : : throw (::com::sun::star::uno::RuntimeException);
199 : :
200 : : //-----------------------------------------------------------------
201 : : // ::com::sun::star::lang::XComponent (base of XController)
202 : : //-----------------------------------------------------------------
203 : : virtual void SAL_CALL
204 : : dispose() throw (::com::sun::star::uno::RuntimeException);
205 : :
206 : : virtual void SAL_CALL
207 : : addEventListener( const ::com::sun::star::uno::Reference<
208 : : ::com::sun::star::lang::XEventListener > & xListener )
209 : : throw (::com::sun::star::uno::RuntimeException);
210 : :
211 : : virtual void SAL_CALL
212 : : removeEventListener( const ::com::sun::star::uno::Reference<
213 : : ::com::sun::star::lang::XEventListener > & xListener )
214 : : throw (::com::sun::star::uno::RuntimeException);
215 : :
216 : : //-----------------------------------------------------------------
217 : : // ::com::sun::star::frame::XDispatchProvider (required interface)
218 : : //-----------------------------------------------------------------
219 : : virtual ::com::sun::star::uno::Reference<
220 : : ::com::sun::star::frame::XDispatch> SAL_CALL
221 : : queryDispatch( const ::com::sun::star::util::URL& rURL
222 : : , const rtl::OUString& rTargetFrameName
223 : : , sal_Int32 nSearchFlags)
224 : : throw (::com::sun::star::uno::RuntimeException);
225 : :
226 : : virtual ::com::sun::star::uno::Sequence<
227 : : ::com::sun::star::uno::Reference<
228 : : ::com::sun::star::frame::XDispatch > > SAL_CALL
229 : : queryDispatches( const ::com::sun::star::uno::Sequence<
230 : : ::com::sun::star::frame::DispatchDescriptor > & xDescripts)
231 : : throw (::com::sun::star::uno::RuntimeException);
232 : :
233 : : //-----------------------------------------------------------------
234 : : // ::com::sun::star::view::XSelectionSupplier (optional interface)
235 : : //-----------------------------------------------------------------
236 : : virtual sal_Bool SAL_CALL
237 : : select( const ::com::sun::star::uno::Any& rSelection )
238 : : throw ( com::sun::star::lang::IllegalArgumentException );
239 : :
240 : : virtual ::com::sun::star::uno::Any SAL_CALL
241 : : getSelection() throw (::com::sun::star::uno::RuntimeException);
242 : :
243 : : virtual void SAL_CALL
244 : : addSelectionChangeListener( const ::com::sun::star::uno::Reference<
245 : : com::sun::star::view::XSelectionChangeListener > & xListener )
246 : : throw (::com::sun::star::uno::RuntimeException);
247 : :
248 : : virtual void SAL_CALL
249 : : removeSelectionChangeListener( const ::com::sun::star::uno::Reference<
250 : : com::sun::star::view::XSelectionChangeListener > & xListener )
251 : : throw (::com::sun::star::uno::RuntimeException);
252 : :
253 : : //-----------------------------------------------------------------
254 : : // ::com::sun::star::ui::XContextMenuInterception (optional interface)
255 : : //-----------------------------------------------------------------
256 : : virtual void SAL_CALL
257 : : registerContextMenuInterceptor( const ::com::sun::star::uno::Reference<
258 : : ::com::sun::star::ui::XContextMenuInterceptor > & xInterceptor)
259 : : throw (::com::sun::star::uno::RuntimeException);
260 : :
261 : : virtual void SAL_CALL
262 : : releaseContextMenuInterceptor( const ::com::sun::star::uno::Reference<
263 : : ::com::sun::star::ui::XContextMenuInterceptor > & xInterceptor)
264 : : throw (::com::sun::star::uno::RuntimeException);
265 : :
266 : :
267 : : //-----------------------------------------------------------------
268 : : //-----------------------------------------------------------------
269 : : //additional interfaces
270 : :
271 : : //-----------------------------------------------------------------
272 : : // ::com::sun::star::util::XCloseListener
273 : : //-----------------------------------------------------------------
274 : : virtual void SAL_CALL
275 : : queryClosing( const ::com::sun::star::lang::EventObject& Source
276 : : , sal_Bool GetsOwnership )
277 : : throw (::com::sun::star::util::CloseVetoException
278 : : , ::com::sun::star::uno::RuntimeException);
279 : :
280 : : virtual void SAL_CALL
281 : : notifyClosing( const ::com::sun::star::lang::EventObject& Source )
282 : : throw (::com::sun::star::uno::RuntimeException);
283 : :
284 : : //-------------------------------------------------------------------------------------
285 : : // ::com::sun::star::util::XEventListener (base of XCloseListener and XModifyListener)
286 : : //-------------------------------------------------------------------------------------
287 : : virtual void SAL_CALL
288 : : disposing( const ::com::sun::star::lang::EventObject& Source )
289 : : throw (::com::sun::star::uno::RuntimeException);
290 : :
291 : : //-----------------------------------------------------------------
292 : : // ::com::sun::star::frame::XDispatch
293 : : //-----------------------------------------------------------------
294 : :
295 : : virtual void SAL_CALL
296 : : dispatch( const ::com::sun::star::util::URL& aURL
297 : : , const ::com::sun::star::uno::Sequence<
298 : : ::com::sun::star::beans::PropertyValue >& aArgs )
299 : : throw (::com::sun::star::uno::RuntimeException);
300 : :
301 : : virtual void SAL_CALL
302 : : addStatusListener( const ::com::sun::star::uno::Reference<
303 : : ::com::sun::star::frame::XStatusListener >& xControl
304 : : , const ::com::sun::star::util::URL& aURL )
305 : : throw (::com::sun::star::uno::RuntimeException);
306 : :
307 : : virtual void SAL_CALL
308 : : removeStatusListener( const ::com::sun::star::uno::Reference<
309 : : ::com::sun::star::frame::XStatusListener >& xControl
310 : : , const ::com::sun::star::util::URL& aURL )
311 : : throw (::com::sun::star::uno::RuntimeException);
312 : :
313 : : //-----------------------------------------------------------------
314 : : // ::com::sun::star::awt::XWindow
315 : : //-----------------------------------------------------------------
316 : : virtual void SAL_CALL
317 : : setPosSize( sal_Int32 X, sal_Int32 Y
318 : : , sal_Int32 Width, sal_Int32 Height, sal_Int16 Flags )
319 : : throw (::com::sun::star::uno::RuntimeException);
320 : :
321 : : virtual ::com::sun::star::awt::Rectangle SAL_CALL
322 : : getPosSize()
323 : : throw (::com::sun::star::uno::RuntimeException);
324 : :
325 : : virtual void SAL_CALL
326 : : setVisible( sal_Bool Visible )
327 : : throw (::com::sun::star::uno::RuntimeException);
328 : :
329 : : virtual void SAL_CALL
330 : : setEnable( sal_Bool Enable )
331 : : throw (::com::sun::star::uno::RuntimeException);
332 : :
333 : : virtual void SAL_CALL
334 : : setFocus() throw (::com::sun::star::uno::RuntimeException);
335 : :
336 : : //----------------
337 : : virtual void SAL_CALL
338 : : addWindowListener( const ::com::sun::star::uno::Reference<
339 : : ::com::sun::star::awt::XWindowListener >& xListener )
340 : : throw (::com::sun::star::uno::RuntimeException);
341 : :
342 : : virtual void SAL_CALL
343 : : removeWindowListener( const ::com::sun::star::uno::Reference<
344 : : ::com::sun::star::awt::XWindowListener >& xListener )
345 : : throw (::com::sun::star::uno::RuntimeException);
346 : :
347 : : virtual void SAL_CALL
348 : : addFocusListener( const ::com::sun::star::uno::Reference<
349 : : ::com::sun::star::awt::XFocusListener >& xListener )
350 : : throw (::com::sun::star::uno::RuntimeException);
351 : :
352 : : virtual void SAL_CALL
353 : : removeFocusListener( const ::com::sun::star::uno::Reference<
354 : : ::com::sun::star::awt::XFocusListener >& xListener )
355 : : throw (::com::sun::star::uno::RuntimeException);
356 : :
357 : : virtual void SAL_CALL
358 : : addKeyListener( const ::com::sun::star::uno::Reference<
359 : : ::com::sun::star::awt::XKeyListener >& xListener )
360 : : throw (::com::sun::star::uno::RuntimeException);
361 : :
362 : : virtual void SAL_CALL
363 : : removeKeyListener( const ::com::sun::star::uno::Reference<
364 : : ::com::sun::star::awt::XKeyListener >& xListener )
365 : : throw (::com::sun::star::uno::RuntimeException);
366 : :
367 : : virtual void SAL_CALL
368 : : addMouseListener( const ::com::sun::star::uno::Reference<
369 : : ::com::sun::star::awt::XMouseListener >& xListener )
370 : : throw (::com::sun::star::uno::RuntimeException);
371 : :
372 : : virtual void SAL_CALL
373 : : removeMouseListener( const ::com::sun::star::uno::Reference<
374 : : ::com::sun::star::awt::XMouseListener >& xListener )
375 : : throw (::com::sun::star::uno::RuntimeException);
376 : :
377 : : virtual void SAL_CALL
378 : : addMouseMotionListener( const ::com::sun::star::uno::Reference<
379 : : ::com::sun::star::awt::XMouseMotionListener >& xListener )
380 : : throw (::com::sun::star::uno::RuntimeException);
381 : :
382 : : virtual void SAL_CALL
383 : : removeMouseMotionListener( const ::com::sun::star::uno::Reference<
384 : : ::com::sun::star::awt::XMouseMotionListener >& xListener )
385 : : throw (::com::sun::star::uno::RuntimeException);
386 : :
387 : : virtual void SAL_CALL
388 : : addPaintListener( const ::com::sun::star::uno::Reference<
389 : : ::com::sun::star::awt::XPaintListener >& xListener )
390 : : throw (::com::sun::star::uno::RuntimeException);
391 : :
392 : : virtual void SAL_CALL
393 : : removePaintListener( const ::com::sun::star::uno::Reference<
394 : : ::com::sun::star::awt::XPaintListener >& xListener )
395 : : throw (::com::sun::star::uno::RuntimeException);
396 : :
397 : : //-----------------------------------------------------------------
398 : : // ::com::sun::star::lang XMultiServiceFactory
399 : : //-----------------------------------------------------------------
400 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
401 : : createInstance( const ::rtl::OUString& aServiceSpecifier )
402 : : throw (::com::sun::star::uno::Exception,
403 : : ::com::sun::star::uno::RuntimeException);
404 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
405 : : createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier,
406 : : const ::com::sun::star::uno::Sequence<
407 : : ::com::sun::star::uno::Any >& Arguments )
408 : : throw (::com::sun::star::uno::Exception,
409 : : ::com::sun::star::uno::RuntimeException);
410 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
411 : : getAvailableServiceNames()
412 : : throw (::com::sun::star::uno::RuntimeException);
413 : :
414 : : //-----------------------------------------------------------------
415 : : // ::com::sun::star::util::XModifyListener
416 : : //-----------------------------------------------------------------
417 : : virtual void SAL_CALL modified(
418 : : const ::com::sun::star::lang::EventObject& aEvent )
419 : : throw (::com::sun::star::uno::RuntimeException);
420 : :
421 : : //-----------------------------------------------------------------
422 : : // ::com::sun::star::util::XModeChangeListener
423 : : //-----------------------------------------------------------------
424 : : virtual void SAL_CALL modeChanged(
425 : : const ::com::sun::star::util::ModeChangeEvent& _rSource )
426 : : throw (::com::sun::star::uno::RuntimeException);
427 : :
428 : : //-----------------------------------------------------------------
429 : : // ::com::sun::star::frame::XLayoutManagerListener
430 : : //-----------------------------------------------------------------
431 : : virtual void SAL_CALL layoutEvent(
432 : : const ::com::sun::star::lang::EventObject& aSource,
433 : : ::sal_Int16 eLayoutEvent,
434 : : const ::com::sun::star::uno::Any& aInfo )
435 : : throw (::com::sun::star::uno::RuntimeException);
436 : :
437 : : //-----------------------------------------------------------------
438 : : // chart2::WindowController
439 : : //-----------------------------------------------------------------
440 : : virtual void PrePaint();
441 : : virtual void execute_Paint( const Rectangle& rRect );
442 : : virtual void execute_MouseButtonDown( const MouseEvent& rMEvt );
443 : : virtual void execute_MouseMove( const MouseEvent& rMEvt );
444 : : virtual void execute_Tracking( const TrackingEvent& rTEvt );
445 : : virtual void execute_MouseButtonUp( const MouseEvent& rMEvt );
446 : : virtual void execute_Resize();
447 : : virtual void execute_Activate();
448 : : virtual void execute_Deactivate();
449 : : virtual void execute_GetFocus();
450 : : virtual void execute_LoseFocus();
451 : : virtual void execute_Command( const CommandEvent& rCEvt );
452 : : virtual bool execute_KeyInput( const KeyEvent& rKEvt );
453 : :
454 : : virtual bool requestQuickHelp(
455 : : ::Point aAtLogicPosition, bool bIsBalloonHelp,
456 : : ::rtl::OUString & rOutQuickHelpText, ::com::sun::star::awt::Rectangle & rOutEqualRect );
457 : :
458 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
459 : :
460 : : //-----------------------------------------------------------------
461 : : //-----------------------------------------------------------------
462 : :
463 : : static bool isObjectDeleteable( const ::com::sun::star::uno::Any& rSelection );
464 : :
465 : 0 : void setDrawMode( ChartDrawMode eMode ) { m_eDrawMode = eMode; }
466 : : ChartDrawMode getDrawMode() const { return m_eDrawMode; }
467 : :
468 : : bool isShapeContext() const;
469 : :
470 : : DECL_LINK( NotifyUndoActionHdl, SdrUndoAction* );
471 : :
472 : : public:
473 : : //-----------------------------------------------------------------
474 : : //-----------------------------------------------------------------
475 : : //-----------------------------------------------------------------
476 : : //-----------------------------------------------------------------
477 : : //private
478 : : //-----------------------------------------------------------------
479 : : //-----------------------------------------------------------------
480 : : //-----------------------------------------------------------------
481 : : //-----------------------------------------------------------------
482 : :
483 : :
484 : : private:
485 : : DrawModelWrapper* GetDrawModelWrapper();
486 : : DrawViewWrapper* GetDrawViewWrapper();
487 : :
488 : : private:
489 : : class TheModelRef;
490 : : friend class ChartController::TheModelRef;
491 : : class RefCountable
492 : : {
493 : : public:
494 : : RefCountable();
495 : : virtual ~RefCountable();
496 : : void acquire();
497 : : void release();
498 : : private:
499 : : sal_Int32 volatile m_nRefCount;
500 : : };
501 : : class TheModel : public RefCountable
502 : : {
503 : : public:
504 : : TheModel( const ::com::sun::star::uno::Reference<
505 : : ::com::sun::star::frame::XModel > & xModel );
506 : :
507 : : virtual ~TheModel();
508 : :
509 : : void SetOwnerShip( sal_Bool bGetsOwnership );
510 : : void addListener( ChartController* pController );
511 : : void removeListener( ChartController* pController );
512 : : void tryTermination();
513 : : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >
514 : 16146 : getModel() const { return m_xModel;}
515 : :
516 : : private:
517 : : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xModel;
518 : : ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable > m_xCloseable;
519 : :
520 : : //the ownership between model and controller is not clear at first
521 : : //each controller might consider himself as owner of the model first
522 : : sal_Bool volatile m_bOwnership;
523 : : //with a XCloseable::close call and during XCloseListener::queryClosing
524 : : //the ownership can be regulated more explicit,
525 : : //if so the ownership is considered to be well known
526 : : sal_Bool volatile m_bOwnershipIsWellKnown;
527 : : };
528 : : class TheModelRef
529 : : {
530 : : public:
531 : : TheModelRef( TheModel* pTheModel, ::osl::Mutex& rMutex );
532 : : TheModelRef( const TheModelRef& rTheModel, ::osl::Mutex& rMutex );
533 : : TheModelRef& operator=(ChartController::TheModel* pTheModel);
534 : : TheModelRef& operator=(const TheModelRef& rTheModel);
535 : : virtual ~TheModelRef();
536 : : sal_Bool is() const;
537 : 32792 : TheModel* operator->() const { return m_pTheModel; }
538 : : private:
539 : : TheModel* m_pTheModel;
540 : : ::osl::Mutex& m_rModelMutex;
541 : : };
542 : :
543 : : private:
544 : : mutable ::apphelper::LifeTimeManager m_aLifeTimeManager;
545 : :
546 : : mutable ::osl::Mutex m_aControllerMutex;
547 : : sal_Bool volatile m_bSuspended;
548 : : sal_Bool volatile m_bCanClose;
549 : :
550 : : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> m_xCC;
551 : :
552 : : //model
553 : : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame;
554 : : mutable ::osl::Mutex m_aModelMutex;
555 : : TheModelRef m_aModel;
556 : :
557 : : //view
558 : : ChartWindow* m_pChartWindow;
559 : : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xViewWindow;
560 : : ::com::sun::star::uno::Reference<
561 : : ::com::sun::star::uno::XInterface > m_xChartView;
562 : : ::boost::shared_ptr< DrawModelWrapper > m_pDrawModelWrapper;
563 : : DrawViewWrapper* m_pDrawViewWrapper;
564 : :
565 : : Selection m_aSelection;
566 : : SdrDragMode m_eDragMode;
567 : :
568 : : Timer m_aDoubleClickTimer;
569 : : bool volatile m_bWaitingForDoubleClick;
570 : : bool volatile m_bWaitingForMouseUp;
571 : :
572 : : bool volatile m_bConnectingToView;
573 : :
574 : : ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > m_xUndoManager;
575 : : ::std::auto_ptr< UndoGuard > m_pTextActionUndoGuard;
576 : : /// needed for dispatching URLs in FeatureStateEvents
577 : : mutable ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xURLTransformer;
578 : :
579 : : ::std::auto_ptr< ::svt::AcceleratorExecute > m_apAccelExecute;
580 : :
581 : : CommandDispatchContainer m_aDispatchContainer;
582 : :
583 : : ::std::auto_ptr< DropTargetHelper > m_apDropTargetHelper;
584 : : ::com::sun::star::uno::Reference<
585 : : ::com::sun::star::frame::XLayoutManagerEventBroadcaster >
586 : : m_xLayoutManagerEventBroadcaster;
587 : :
588 : : ChartDrawMode m_eDrawMode;
589 : :
590 : : private:
591 : : //private methods
592 : :
593 : : sal_Bool impl_isDisposedOrSuspended() const;
594 : : ::std::auto_ptr< ReferenceSizeProvider > impl_createReferenceSizeProvider();
595 : : void impl_adaptDataSeriesAutoResize();
596 : :
597 : : void impl_createDrawViewController();
598 : : void impl_deleteDrawViewController();
599 : :
600 : : //executeDispatch methods
601 : : void SAL_CALL executeDispatch_ObjectProperties();
602 : : void SAL_CALL executeDispatch_FormatObject( const ::rtl::OUString& rDispatchCommand );
603 : : void SAL_CALL executeDlg_ObjectProperties( const ::rtl::OUString& rObjectCID );
604 : : bool executeDlg_ObjectProperties_withoutUndoGuard( const ::rtl::OUString& rObjectCID, bool bOkClickOnUnchangedDialogSouldBeRatedAsSuccessAlso );
605 : :
606 : : void SAL_CALL executeDispatch_ChartType();
607 : :
608 : : void executeDispatch_InsertTitles();
609 : : void executeDispatch_InsertLegend();
610 : : void executeDispatch_DeleteLegend();
611 : : void executeDispatch_OpenLegendDialog();
612 : : void executeDispatch_InsertAxes();
613 : : void executeDispatch_InsertGrid();
614 : :
615 : : void executeDispatch_InsertMenu_DataLabels();
616 : : void executeDispatch_InsertMenu_Trendlines();
617 : : void executeDispatch_InsertMenu_MeanValues();
618 : :
619 : : void executeDispatch_InsertMeanValue();
620 : : void executeDispatch_InsertTrendline();
621 : : void executeDispatch_InsertTrendlineEquation( bool bInsertR2=false );
622 : : void executeDispatch_InsertErrorBars( bool bYError );
623 : :
624 : : void executeDispatch_InsertR2Value();
625 : : void executeDispatch_DeleteR2Value();
626 : :
627 : : void executeDispatch_DeleteMeanValue();
628 : : void executeDispatch_DeleteTrendline();
629 : : void executeDispatch_DeleteTrendlineEquation();
630 : : void executeDispatch_DeleteErrorBars( bool bYError );
631 : :
632 : : void executeDispatch_InsertDataLabels();
633 : : void executeDispatch_InsertDataLabel();
634 : : void executeDispatch_DeleteDataLabels();
635 : : void executeDispatch_DeleteDataLabel();
636 : :
637 : : void executeDispatch_ResetAllDataPoints();
638 : : void executeDispatch_ResetDataPoint();
639 : :
640 : : void executeDispatch_InsertAxis();
641 : : void executeDispatch_InsertAxisTitle();
642 : : void executeDispatch_InsertMajorGrid();
643 : : void executeDispatch_InsertMinorGrid();
644 : : void executeDispatch_DeleteAxis();
645 : : void executeDispatch_DeleteMajorGrid();
646 : : void executeDispatch_DeleteMinorGrid();
647 : :
648 : : void SAL_CALL executeDispatch_InsertSpecialCharacter();
649 : : void SAL_CALL executeDispatch_EditText( const Point* pMousePixel = NULL );
650 : : void SAL_CALL executeDispatch_SourceData();
651 : : void SAL_CALL executeDispatch_MoveSeries( sal_Bool bForward );
652 : :
653 : : void StartTextEdit( const Point* pMousePixel = NULL );
654 : : bool EndTextEdit();
655 : :
656 : : void SAL_CALL executeDispatch_View3D();
657 : : void SAL_CALL executeDispatch_PositionAndSize();
658 : :
659 : : void executeDispatch_EditData();
660 : :
661 : : void executeDispatch_NewArrangement();
662 : : void executeDispatch_ScaleText();
663 : :
664 : : void executeDispatch_Paste();
665 : : void executeDispatch_Copy();
666 : : void executeDispatch_Cut();
667 : : bool executeDispatch_Delete();
668 : : void executeDispatch_ToggleLegend();
669 : : void executeDispatch_ToggleGridHorizontal();
670 : :
671 : : void impl_ShapeControllerDispatch( const ::com::sun::star::util::URL& rURL,
672 : : const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rArgs );
673 : :
674 : : DECL_LINK( DoubleClickWaitingHdl, void* );
675 : : void execute_DoubleClick( const Point* pMousePixel = NULL );
676 : : void startDoubleClickWaiting();
677 : : void stopDoubleClickWaiting();
678 : :
679 : : void impl_selectObjectAndNotiy();
680 : : void impl_notifySelectionChangeListeners();
681 : : void impl_invalidateAccessible();
682 : : void impl_initializeAccessible();
683 : : void impl_initializeAccessible( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XInitialization >& xInit );
684 : :
685 : : //sets the model member to null if it equals the parameter
686 : : //returns true if successful
687 : : bool impl_releaseThisModel( const ::com::sun::star::uno::Reference<
688 : : ::com::sun::star::uno::XInterface > & xModel );
689 : :
690 : : enum eMoveOrResizeType
691 : : {
692 : : MOVE_OBJECT,
693 : : CENTERED_RESIZE_OBJECT
694 : : };
695 : : /// @return </sal_True>, if resize/move was successful
696 : : bool impl_moveOrResizeObject(
697 : : const ::rtl::OUString & rCID, eMoveOrResizeType eType, double fAmountLogicX, double fAmountLogicY );
698 : : bool impl_DragDataPoint( const ::rtl::OUString & rCID, double fOffset );
699 : :
700 : : ::std::set< ::rtl::OUString > impl_getAvailableCommands();
701 : :
702 : : /** Creates a helper accesibility class that must be initialized via XInitialization. For
703 : : parameters see
704 : :
705 : : The returned object should not be used directly. Instead a proxy object
706 : : should use this helper to retrieve its children and add them to its own
707 : : children.
708 : : */
709 : : ::com::sun::star::uno::Reference<
710 : : ::com::sun::star::accessibility::XAccessibleContext >
711 : : impl_createAccessibleTextContext();
712 : :
713 : : void impl_PasteGraphic( ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > & xGraphic,
714 : : const ::Point & aPosition );
715 : : void impl_PasteShapes( SdrModel* pModel );
716 : : void impl_PasteStringAsTextShape( const ::rtl::OUString& rString, const ::com::sun::star::awt::Point& rPosition );
717 : : void impl_SetMousePointer( const MouseEvent & rEvent );
718 : :
719 : : void impl_ClearSelection();
720 : :
721 : : void impl_switchDiagramPositioningToExcludingPositioning();
722 : : };
723 : :
724 : : //.............................................................................
725 : : } // namespace chart
726 : : //.............................................................................
727 : :
728 : : #endif
729 : :
730 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|