Update ooo320-m1
[ooovba.git] / chart2 / source / controller / main / ChartController_Window.cxx
blob732f9d2743a6fdcf691966ed4cad47990d3d1c61
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ChartController_Window.cxx,v $
10 * $Revision: 1.31.24.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_chart2.hxx"
33 #include "ChartController.hxx"
34 #include "PositionAndSizeHelper.hxx"
35 #include "ObjectIdentifier.hxx"
36 #include "ChartWindow.hxx"
37 #include "ResId.hxx"
38 #include "CommonConverters.hxx"
39 #include "ChartModelHelper.hxx"
40 #include "DiagramHelper.hxx"
41 #include "TitleHelper.hxx"
42 #include "UndoGuard.hxx"
43 #include "ControllerLockGuard.hxx"
44 #include "ObjectNameProvider.hxx"
45 #include "Strings.hrc"
46 #include "SchSlotIds.hxx"
47 #include "macros.hxx"
48 #include "DragMethod_PieSegment.hxx"
49 #include "DragMethod_RotateDiagram.hxx"
50 #include "ObjectHierarchy.hxx"
51 #include "chartview/ExplicitValueProvider.hxx"
52 #include "RelativePositionHelper.hxx"
53 #include "chartview/DrawModelWrapper.hxx"
54 #include "RegressionCurveHelper.hxx"
55 #include "StatisticsHelper.hxx"
56 #include "DataSeriesHelper.hxx"
57 #include "ContainerHelper.hxx"
58 #include "AxisHelper.hxx"
59 #include "LegendHelper.hxx"
60 #include "servicenames_charttypes.hxx"
62 #include <com/sun/star/chart2/RelativePosition.hpp>
63 #include <com/sun/star/chart2/RelativeSize.hpp>
64 #include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
66 #include <com/sun/star/frame/XDispatchHelper.hpp>
67 #include <com/sun/star/frame/FrameSearchFlag.hpp>
68 #include <com/sun/star/util/XUpdatable.hpp>
69 #include <comphelper/InlineContainer.hxx>
71 #include <svtools/contextmenuhelper.hxx>
72 #include <toolkit/awt/vclxmenu.hxx>
74 #include <svx/svxids.hrc>
75 #include <svx/ActionDescriptionProvider.hxx>
77 // header for class E3dObject
78 #include <svx/obj3d.hxx>
79 // header for class E3dScene
80 #include <svx/scene3d.hxx>
81 // header for class SdrDragMethod
82 #include <svx/svddrgmt.hxx>
83 #include <vcl/svapp.hxx>
84 #include <vos/mutex.hxx>
86 // for InfoBox
87 #include <vcl/msgbox.hxx>
89 #include <rtl/math.hxx>
90 #include <svtools/acceleratorexecute.hxx>
92 #define DRGPIX 2 // Drag MinMove in Pixel
94 using namespace ::com::sun::star;
95 using namespace ::com::sun::star::chart2;
96 using ::com::sun::star::uno::Reference;
97 using ::rtl::OUString;
99 //.............................................................................
100 namespace chart
102 //.............................................................................
104 namespace
106 bool lcl_GrowAndShiftLogic(
107 RelativePosition & rInOutRelPos,
108 RelativeSize & rInOutRelSize,
109 const awt::Size & rRefSize,
110 double fGrowLogicX,
111 double fGrowLogicY )
113 if( rRefSize.Width == 0 ||
114 rRefSize.Height == 0 )
115 return false;
117 double fRelativeGrowX = fGrowLogicX / rRefSize.Width;
118 double fRelativeGrowY = fGrowLogicY / rRefSize.Height;
120 return ::chart::RelativePositionHelper::centerGrow(
121 rInOutRelPos, rInOutRelSize,
122 fRelativeGrowX, fRelativeGrowY,
123 /* bCheck = */ true );
126 bool lcl_MoveObjectLogic(
127 RelativePosition & rInOutRelPos,
128 RelativeSize & rObjectSize,
129 const awt::Size & rRefSize,
130 double fShiftLogicX,
131 double fShiftLogicY )
133 if( rRefSize.Width == 0 ||
134 rRefSize.Height == 0 )
135 return false;
137 double fRelativeShiftX = fShiftLogicX / rRefSize.Width;
138 double fRelativeShiftY = fShiftLogicY / rRefSize.Height;
140 return ::chart::RelativePositionHelper::moveObject(
141 rInOutRelPos, rObjectSize,
142 fRelativeShiftX, fRelativeShiftY,
143 /* bCheck = */ true );
146 void lcl_insertMenuCommand(
147 const uno::Reference< awt::XPopupMenu > & xMenu,
148 const uno::Reference< awt::XMenuExtended > & xMenuEx,
149 sal_Int16 nId, const ::rtl::OUString & rCommand )
151 static ::rtl::OUString aEmptyString;
152 xMenu->insertItem( nId, aEmptyString, 0, -1 );
153 xMenuEx->setCommand( nId, rCommand );
156 OUString lcl_getFormatCommandForObjectCID( const OUString& rCID )
158 OUString aDispatchCommand( C2U(".uno:FormatSelection") );
160 ObjectType eObjectType = ObjectIdentifier::getObjectType( rCID );
162 switch(eObjectType)
164 case OBJECTTYPE_DIAGRAM:
165 case OBJECTTYPE_DIAGRAM_WALL:
166 aDispatchCommand = C2U(".uno:FormatWall");
167 break;
168 case OBJECTTYPE_DIAGRAM_FLOOR:
169 aDispatchCommand = C2U(".uno:FormatFloor");
170 break;
171 case OBJECTTYPE_PAGE:
172 aDispatchCommand = C2U(".uno:FormatChartArea");
173 break;
174 case OBJECTTYPE_LEGEND:
175 aDispatchCommand = C2U(".uno:FormatLegend");
176 break;
177 case OBJECTTYPE_TITLE:
178 aDispatchCommand = C2U(".uno:FormatTitle");
179 break;
180 case OBJECTTYPE_LEGEND_ENTRY:
181 aDispatchCommand = C2U(".uno:FormatDataSeries");
182 break;
183 case OBJECTTYPE_AXIS:
184 case OBJECTTYPE_AXIS_UNITLABEL:
185 aDispatchCommand = C2U(".uno:FormatAxis");
186 break;
187 case OBJECTTYPE_GRID:
188 aDispatchCommand = C2U(".uno:FormatMajorGrid");
189 break;
190 case OBJECTTYPE_SUBGRID:
191 aDispatchCommand = C2U(".uno:FormatMinorGrid");
192 break;
193 case OBJECTTYPE_DATA_LABELS:
194 aDispatchCommand = C2U(".uno:FormatDataLabels");
195 break;
196 case OBJECTTYPE_DATA_SERIES:
197 aDispatchCommand = C2U(".uno:FormatDataSeries");
198 break;
199 case OBJECTTYPE_DATA_LABEL:
200 aDispatchCommand = C2U(".uno:FormatDataLabel");
201 break;
202 case OBJECTTYPE_DATA_POINT:
203 aDispatchCommand = C2U(".uno:FormatDataPoint");
204 break;
205 case OBJECTTYPE_DATA_AVERAGE_LINE:
206 aDispatchCommand = C2U(".uno:FormatMeanValue");
207 break;
208 case OBJECTTYPE_DATA_ERRORS:
209 case OBJECTTYPE_DATA_ERRORS_X:
210 case OBJECTTYPE_DATA_ERRORS_Y:
211 case OBJECTTYPE_DATA_ERRORS_Z:
212 aDispatchCommand = C2U(".uno:FormatYErrorBars");
213 break;
214 case OBJECTTYPE_DATA_CURVE:
215 aDispatchCommand = C2U(".uno:FormatTrendline");
216 break;
217 case OBJECTTYPE_DATA_CURVE_EQUATION:
218 aDispatchCommand = C2U(".uno:FormatTrendlineEquation");
219 break;
220 case OBJECTTYPE_DATA_STOCK_RANGE:
221 aDispatchCommand = C2U(".uno:FormatSelection");
222 break;
223 case OBJECTTYPE_DATA_STOCK_LOSS:
224 aDispatchCommand = C2U(".uno:FormatStockLoss");
225 break;
226 case OBJECTTYPE_DATA_STOCK_GAIN:
227 aDispatchCommand = C2U(".uno:FormatStockGain");
228 break;
229 default: //OBJECTTYPE_UNKNOWN
230 break;
232 return aDispatchCommand;
235 } // anonymous namespace
237 const short HITPIX=2; //hit-tolerance in pixel
239 //-----------------------------------------------------------------
240 // awt::XWindow
241 //-----------------------------------------------------------------
242 void SAL_CALL ChartController
243 ::setPosSize( sal_Int32 X, sal_Int32 Y
244 , sal_Int32 Width, sal_Int32 Height, sal_Int16 Flags )
245 throw (uno::RuntimeException)
247 uno::Reference<awt::XWindow> xWindow = m_xViewWindow;
248 Window* pWindow = m_pChartWindow;
250 if(xWindow.is() && pWindow)
252 Size aLogicSize = pWindow->PixelToLogic( Size( Width, Height ), MapMode( MAP_100TH_MM ) );
254 bool bIsEmbedded = true;
255 //todo: for standalone chart: detect wether we are standalone
256 if( bIsEmbedded )
258 //change map mode to fit new size
259 awt::Size aModelPageSize = ChartModelHelper::getPageSize( m_aModel->getModel() );
260 sal_Int32 nScaleXNumerator = aLogicSize.Width();
261 sal_Int32 nScaleXDenominator = aModelPageSize.Width;
262 sal_Int32 nScaleYNumerator = aLogicSize.Height();
263 sal_Int32 nScaleYDenominator = aModelPageSize.Height;
264 MapMode aNewMapMode( MAP_100TH_MM, Point(0,0)
265 , Fraction(nScaleXNumerator,nScaleXDenominator)
266 , Fraction(nScaleYNumerator,nScaleYDenominator) );
267 pWindow->SetMapMode(aNewMapMode);
268 pWindow->SetPosSizePixel( X, Y, Width, Height, Flags );
270 //#i75867# poor quality of ole's alternative view with 3D scenes and zoomfactors besides 100%
271 uno::Reference< beans::XPropertySet > xProp( m_xChartView, uno::UNO_QUERY );
272 if( xProp.is() )
274 uno::Sequence< beans::PropertyValue > aZoomFactors(4);
275 aZoomFactors[0].Name = C2U("ScaleXNumerator");
276 aZoomFactors[0].Value = uno::makeAny( nScaleXNumerator );
277 aZoomFactors[1].Name = C2U("ScaleXDenominator");
278 aZoomFactors[1].Value = uno::makeAny( nScaleXDenominator );
279 aZoomFactors[2].Name = C2U("ScaleYNumerator");
280 aZoomFactors[2].Value = uno::makeAny( nScaleYNumerator );
281 aZoomFactors[3].Name = C2U("ScaleYDenominator");
282 aZoomFactors[3].Value = uno::makeAny( nScaleYDenominator );
283 xProp->setPropertyValue( C2U("ZoomFactors"), uno::makeAny( aZoomFactors ));
286 //a correct work area is at least necessary for correct values in the position and size dialog and for dragging area
287 if(m_pDrawViewWrapper)
289 Rectangle aRect(Point(0,0), pWindow->GetOutputSize());
290 m_pDrawViewWrapper->SetWorkArea( aRect );
293 else
295 //change visarea
296 ChartModelHelper::setPageSize( awt::Size( aLogicSize.Width(), aLogicSize.Height() ), m_aModel->getModel() );
297 pWindow->SetPosSizePixel( X, Y, Width, Height, Flags );
299 pWindow->Invalidate();
303 awt::Rectangle SAL_CALL ChartController
304 ::getPosSize()
305 throw (uno::RuntimeException)
307 //@todo
308 awt::Rectangle aRet(0,0,0,0);
310 uno::Reference<awt::XWindow> xWindow = m_xViewWindow;
311 if(xWindow.is())
312 aRet = xWindow->getPosSize();
314 return aRet;
317 void SAL_CALL ChartController
318 ::setVisible( sal_Bool Visible )
319 throw (uno::RuntimeException)
321 //@todo
322 uno::Reference<awt::XWindow> xWindow = m_xViewWindow;
324 if(xWindow.is())
325 xWindow->setVisible( Visible );
328 void SAL_CALL ChartController
329 ::setEnable( sal_Bool Enable )
330 throw (uno::RuntimeException)
332 //@todo
333 uno::Reference<awt::XWindow> xWindow = m_xViewWindow;
335 if(xWindow.is())
336 xWindow->setEnable( Enable );
339 void SAL_CALL ChartController
340 ::setFocus() throw (uno::RuntimeException)
342 //@todo
343 uno::Reference<awt::XWindow> xWindow = m_xViewWindow;
345 if(xWindow.is())
346 xWindow->setFocus();
349 void SAL_CALL ChartController
350 ::addWindowListener( const uno::Reference<
351 awt::XWindowListener >& xListener )
352 throw (uno::RuntimeException)
354 //@todo
355 uno::Reference<awt::XWindow> xWindow = m_xViewWindow;
357 if(xWindow.is())
358 xWindow->addWindowListener( xListener );
361 void SAL_CALL ChartController
362 ::removeWindowListener( const uno::Reference<
363 awt::XWindowListener >& xListener )
364 throw (uno::RuntimeException)
366 //@todo
367 uno::Reference<awt::XWindow> xWindow = m_xViewWindow;
369 if(xWindow.is())
370 xWindow->removeWindowListener( xListener );
373 void SAL_CALL ChartController
374 ::addFocusListener( const uno::Reference<
375 awt::XFocusListener >& xListener )
376 throw (uno::RuntimeException)
378 //@todo
379 uno::Reference<awt::XWindow> xWindow = m_xViewWindow;
381 if(xWindow.is())
382 xWindow->addFocusListener( xListener );
385 void SAL_CALL ChartController
386 ::removeFocusListener( const uno::Reference<
387 awt::XFocusListener >& xListener )
388 throw (uno::RuntimeException)
390 //@todo
391 uno::Reference<awt::XWindow> xWindow = m_xViewWindow;
393 if(xWindow.is())
394 xWindow->removeFocusListener( xListener );
397 void SAL_CALL ChartController
398 ::addKeyListener( const uno::Reference<
399 awt::XKeyListener >& xListener )
400 throw (uno::RuntimeException)
402 //@todo
403 uno::Reference<awt::XWindow> xWindow = m_xViewWindow;
405 if(xWindow.is())
406 xWindow->addKeyListener( xListener );
409 void SAL_CALL ChartController
410 ::removeKeyListener( const uno::Reference<
411 awt::XKeyListener >& xListener )
412 throw (uno::RuntimeException)
414 //@todo
415 uno::Reference<awt::XWindow> xWindow = m_xViewWindow;
417 if(xWindow.is())
418 xWindow->removeKeyListener( xListener );
421 void SAL_CALL ChartController
422 ::addMouseListener( const uno::Reference<
423 awt::XMouseListener >& xListener )
424 throw (uno::RuntimeException)
426 //@todo
427 uno::Reference<awt::XWindow> xWindow = m_xViewWindow;
429 if(xWindow.is())
430 xWindow->addMouseListener( xListener );
433 void SAL_CALL ChartController
434 ::removeMouseListener( const uno::Reference<
435 awt::XMouseListener >& xListener )
436 throw (uno::RuntimeException)
438 //@todo
439 uno::Reference<awt::XWindow> xWindow = m_xViewWindow;
441 if(xWindow.is())
442 xWindow->removeMouseListener( xListener );
445 void SAL_CALL ChartController
446 ::addMouseMotionListener( const uno::Reference<
447 awt::XMouseMotionListener >& xListener )
448 throw (uno::RuntimeException)
450 //@todo
451 uno::Reference<awt::XWindow> xWindow = m_xViewWindow;
453 if(xWindow.is())
454 xWindow->addMouseMotionListener( xListener );
457 void SAL_CALL ChartController
458 ::removeMouseMotionListener( const uno::Reference<
459 awt::XMouseMotionListener >& xListener )
460 throw (uno::RuntimeException)
462 //@todo
463 uno::Reference<awt::XWindow> xWindow = m_xViewWindow;
465 if(xWindow.is())
466 xWindow->removeMouseMotionListener( xListener );
469 void SAL_CALL ChartController
470 ::addPaintListener( const uno::Reference<
471 awt::XPaintListener >& xListener )
472 throw (uno::RuntimeException)
474 //@todo
475 uno::Reference<awt::XWindow> xWindow = m_xViewWindow;
477 if(xWindow.is())
478 xWindow->addPaintListener( xListener );
481 void SAL_CALL ChartController
482 ::removePaintListener( const uno::Reference<
483 awt::XPaintListener >& xListener )
484 throw (uno::RuntimeException)
486 //@todo
487 uno::Reference<awt::XWindow> xWindow = m_xViewWindow;
489 if(xWindow.is())
490 xWindow->removePaintListener( xListener );
493 //-----------------------------------------------------------------
494 // impl vcl window controller methods
495 //-----------------------------------------------------------------
496 void ChartController::PrePaint()
498 // forward VCLs PrePaint window event to DrawingLayer
499 DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper;
501 if(pDrawViewWrapper)
503 pDrawViewWrapper->PrePaint();
507 void ChartController::execute_Paint( const Rectangle& rRect )
511 //better performance for big data
512 uno::Reference< beans::XPropertySet > xProp( m_xChartView, uno::UNO_QUERY );
513 if( xProp.is() )
515 awt::Size aResolution(1000,1000);
517 ::vos::OGuard aGuard( Application::GetSolarMutex());
518 if( m_pChartWindow )
520 aResolution.Width = m_pChartWindow->GetSizePixel().Width();
521 aResolution.Height = m_pChartWindow->GetSizePixel().Height();
524 xProp->setPropertyValue( C2U("Resolution"), uno::makeAny( aResolution ));
528 uno::Reference< util::XUpdatable > xUpdatable( m_xChartView, uno::UNO_QUERY );
529 if( xUpdatable.is() )
530 xUpdatable->update();
532 Window* pWindow = m_pChartWindow;
534 ::vos::OGuard aGuard( Application::GetSolarMutex());
535 DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper;
536 if(pDrawViewWrapper)
537 pDrawViewWrapper->CompleteRedraw(pWindow, Region(rRect) );
540 catch( uno::Exception & ex )
542 ASSERT_EXCEPTION( ex );
544 catch( ... )
549 bool isDoubleClick( const MouseEvent& rMEvt )
551 return rMEvt.GetClicks() == 2 && rMEvt.IsLeft() &&
552 !rMEvt.IsMod1() && !rMEvt.IsMod2() && !rMEvt.IsShift();
555 //-----------------------------------------------------------------------------
556 //-----------------------------------------------------------------------------
557 //-----------------------------------------------------------------------------
559 void ChartController::startDoubleClickWaiting()
561 m_bWaitingForDoubleClick = true;
563 ULONG nDblClkTime = 500;
564 if( m_pChartWindow )
566 const MouseSettings& rMSettings = m_pChartWindow->GetSettings().GetMouseSettings();
567 nDblClkTime = rMSettings.GetDoubleClickTime();
569 m_aDoubleClickTimer.SetTimeout( nDblClkTime );
570 m_aDoubleClickTimer.Start();
573 void ChartController::stopDoubleClickWaiting()
575 m_aDoubleClickTimer.Stop();
576 m_bWaitingForDoubleClick = false;
579 IMPL_LINK( ChartController, DoubleClickWaitingHdl, void*, EMPTYARG )
581 m_bWaitingForDoubleClick = false;
583 if( !m_bWaitingForMouseUp && m_aSelection.maybeSwitchSelectionAfterSingleClickWasEnsured() )
585 this->impl_selectObjectAndNotiy();
586 if( m_pChartWindow )
588 Window::PointerState aPointerState( m_pChartWindow->GetPointerState() );
589 MouseEvent aMouseEvent( aPointerState.maPos,1/*nClicks*/,
590 0/*nMode*/, static_cast< USHORT >( aPointerState.mnState )/*nButtons*/,
591 0/*nModifier*/ );
592 impl_SetMousePointer( aMouseEvent );
596 return 0;
599 //------------------------------------------------------------------------
601 void ChartController::execute_MouseButtonDown( const MouseEvent& rMEvt )
603 ::vos::OGuard aGuard( Application::GetSolarMutex());
605 m_bWaitingForMouseUp = true;
607 if( isDoubleClick(rMEvt) )
608 stopDoubleClickWaiting();
609 else
610 startDoubleClickWaiting();
612 m_aSelection.remindSelectionBeforeMouseDown();
614 Window* pWindow = m_pChartWindow;
615 DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper;
616 if(!pWindow || !pDrawViewWrapper )
617 return;
619 Point aMPos = pWindow->PixelToLogic(rMEvt.GetPosPixel());
621 if ( MOUSE_LEFT == rMEvt.GetButtons() )
623 pWindow->GrabFocus();
624 pWindow->CaptureMouse();
627 if( pDrawViewWrapper->IsTextEdit() )
629 if( pDrawViewWrapper->IsTextEditHit( aMPos, HITPIX) )
631 pDrawViewWrapper->MouseButtonDown(rMEvt,m_pChartWindow);
632 return;
634 else
636 this->EndTextEdit();
640 //abort running action
641 if( pDrawViewWrapper->IsAction() )
643 if( rMEvt.IsRight() )
644 pDrawViewWrapper->BckAction();
645 return;
648 if( isDoubleClick(rMEvt) ) //do not change selection if double click
649 return;//double click is handled further in mousebutton up
651 SdrHdl* pHitSelectionHdl = 0;
652 //switch from move to resize if handle is hit on a resizeable object
653 if( m_aSelection.isResizeableObjectSelected() )
654 pHitSelectionHdl = pDrawViewWrapper->PickHandle( aMPos );
655 //only change selection if no selection handles are hit
656 if( !pHitSelectionHdl )
658 m_aSelection.adaptSelectionToNewPos( aMPos, pDrawViewWrapper
659 , rMEvt.IsRight(), m_bWaitingForDoubleClick );
661 if( !m_aSelection.isRotateableObjectSelected( m_aModel->getModel() ) )
663 m_eDragMode = SDRDRAG_MOVE;
664 pDrawViewWrapper->SetDragMode(m_eDragMode);
667 m_aSelection.applySelection(pDrawViewWrapper);
669 if( m_aSelection.isDragableObjectSelected()
670 && !rMEvt.IsRight() )
672 //start drag
673 USHORT nDrgLog = (USHORT)pWindow->PixelToLogic(Size(DRGPIX,0)).Width();
674 SdrDragMethod* pDragMethod = NULL;
676 //change selection to 3D scene if rotate mode
677 SdrDragMode eDragMode = pDrawViewWrapper->GetDragMode();
678 if( SDRDRAG_ROTATE==eDragMode )
680 E3dScene* pScene = SelectionHelper::getSceneToRotate( pDrawViewWrapper->getNamedSdrObject( m_aSelection.getSelectedCID() ) );
681 if( pScene )
683 DragMethod_RotateDiagram::RotationDirection eRotationDirection(DragMethod_RotateDiagram::ROTATIONDIRECTION_FREE);
684 if(pHitSelectionHdl)
686 SdrHdlKind eKind = pHitSelectionHdl->GetKind();
687 if( eKind==HDL_UPPER || eKind==HDL_LOWER )
688 eRotationDirection = DragMethod_RotateDiagram::ROTATIONDIRECTION_X;
689 else if( eKind==HDL_LEFT || eKind==HDL_RIGHT )
690 eRotationDirection = DragMethod_RotateDiagram::ROTATIONDIRECTION_Y;
691 else if( eKind==HDL_UPLFT || eKind==HDL_UPRGT || eKind==HDL_LWLFT || eKind==HDL_LWRGT )
692 eRotationDirection = DragMethod_RotateDiagram::ROTATIONDIRECTION_Z;
694 pDragMethod = new DragMethod_RotateDiagram( *pDrawViewWrapper, m_aSelection.getSelectedCID(), m_aModel->getModel(), eRotationDirection );
697 else
699 rtl::OUString aDragMethodServiceName( ObjectIdentifier::getDragMethodServiceName( m_aSelection.getSelectedCID() ) );
700 if( aDragMethodServiceName.equals( ObjectIdentifier::getPieSegmentDragMethodServiceName() ) )
701 pDragMethod = new DragMethod_PieSegment( *pDrawViewWrapper, m_aSelection.getSelectedCID(), m_aModel->getModel() );
703 pDrawViewWrapper->SdrView::BegDragObj(aMPos, NULL, pHitSelectionHdl, nDrgLog, pDragMethod);
706 impl_SetMousePointer( rMEvt );
709 void ChartController::execute_MouseMove( const MouseEvent& rMEvt )
711 ::vos::OGuard aGuard( Application::GetSolarMutex());
713 Window* pWindow = m_pChartWindow;
714 DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper;
715 if(!pWindow || !pDrawViewWrapper)
716 return;
718 if( m_pDrawViewWrapper->IsTextEdit() )
720 if( m_pDrawViewWrapper->MouseMove(rMEvt,m_pChartWindow) )
721 return;
724 if(pDrawViewWrapper->IsAction())
726 pDrawViewWrapper->MovAction( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
729 //?? pDrawViewWrapper->GetPageView()->DragPoly();
731 impl_SetMousePointer( rMEvt );
733 void ChartController::execute_Tracking( const TrackingEvent& /* rTEvt */ )
737 //-----------------
739 void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt )
741 ControllerLockGuard aCLGuard( m_aModel->getModel());
742 m_bWaitingForMouseUp = false;
743 bool bNotifySelectionChange = false;
745 ::vos::OGuard aGuard( Application::GetSolarMutex());
747 Window* pWindow = m_pChartWindow;
748 DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper;
749 if(!pWindow || !pDrawViewWrapper)
750 return;
752 Point aMPos = pWindow->PixelToLogic(rMEvt.GetPosPixel());
754 if(pDrawViewWrapper->IsTextEdit())
756 if( pDrawViewWrapper->MouseButtonUp(rMEvt,m_pChartWindow) )
757 return;
760 if(pDrawViewWrapper->IsDragObj())
762 bool bDraggingDone = false;
763 SdrDragMethod* pDragMethod = pDrawViewWrapper->SdrView::GetDragMethod();
764 bool bIsMoveOnly = pDragMethod ? pDragMethod->getMoveOnly() : false;
765 DragMethod_Base* pChartDragMethod = dynamic_cast< DragMethod_Base* >(pDragMethod);
766 if( pChartDragMethod )
768 UndoGuard aUndoGuard( pChartDragMethod->getUndoDescription(),
769 m_xUndoManager, m_aModel->getModel() );
771 if( pDrawViewWrapper->EndDragObj(false) )
773 bDraggingDone = true;
774 aUndoGuard.commitAction();
778 if( !bDraggingDone && pDrawViewWrapper->EndDragObj(false) )
782 //end move or size
783 SdrObject* pObj = pDrawViewWrapper->getSelectedObject();
784 if( pObj )
786 Rectangle aObjectRect = pObj->GetSnapRect();
787 awt::Size aPageSize( ChartModelHelper::getPageSize( m_aModel->getModel() ) );
788 Rectangle aPageRect( 0,0,aPageSize.Width,aPageSize.Height );
790 const E3dObject* pE3dObject = dynamic_cast< const E3dObject*>( pObj );
791 if( pE3dObject )
792 aObjectRect = pE3dObject->GetScene()->GetSnapRect();
794 ActionDescriptionProvider::ActionType eActionType(ActionDescriptionProvider::MOVE);
795 if( !bIsMoveOnly && m_aSelection.isResizeableObjectSelected() )
796 eActionType = ActionDescriptionProvider::RESIZE;
798 UndoGuard aUndoGuard(
799 ActionDescriptionProvider::createDescription(
800 eActionType,
801 ObjectNameProvider::getName( ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() ))),
802 m_xUndoManager, m_aModel->getModel() );
803 bool bChanged = PositionAndSizeHelper::moveObject( m_aSelection.getSelectedCID()
804 , m_aModel->getModel()
805 , awt::Rectangle(aObjectRect.getX(),aObjectRect.getY(),aObjectRect.getWidth(),aObjectRect.getHeight())
806 , awt::Rectangle(aPageRect.getX(),aPageRect.getY(),aPageRect.getWidth(),aPageRect.getHeight())
807 , m_xChartView );
808 if( bChanged )
810 bDraggingDone = true;
811 aUndoGuard.commitAction();
815 catch( uno::Exception & ex )
817 ASSERT_EXCEPTION( ex );
819 //all wanted model changes will take effect
820 //and all unwanted view modifications are cleaned
823 if( !bDraggingDone ) //mouse wasn't moved while dragging
825 bool bClickedTwiceOnDragableObject = SelectionHelper::isDragableObjectHitTwice( aMPos, m_aSelection.getSelectedCID(), *pDrawViewWrapper );
826 bool bIsRotateable = m_aSelection.isRotateableObjectSelected( m_aModel->getModel() );
828 //toggel between move and rotate
829 if( bIsRotateable && bClickedTwiceOnDragableObject && SDRDRAG_MOVE==m_eDragMode )
830 m_eDragMode=SDRDRAG_ROTATE;
831 else
832 m_eDragMode=SDRDRAG_MOVE;
834 pDrawViewWrapper->SetDragMode(m_eDragMode);
836 if( !m_bWaitingForDoubleClick && m_aSelection.maybeSwitchSelectionAfterSingleClickWasEnsured() )
838 this->impl_selectObjectAndNotiy();
841 else
842 m_aSelection.resetPossibleSelectionAfterSingleClickWasEnsured();
844 else if( isDoubleClick(rMEvt) )
845 execute_DoubleClick();
847 //@todo ForcePointer(&rMEvt);
848 pWindow->ReleaseMouse();
850 if( m_aSelection.isSelectionDifferentFromBeforeMouseDown() )
851 bNotifySelectionChange = true;
854 impl_SetMousePointer( rMEvt );
856 if(bNotifySelectionChange)
857 impl_notifySelectionChangeListeners();
860 void ChartController::execute_DoubleClick()
862 ObjectType eObjectType = ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() );
863 if( OBJECTTYPE_TITLE==eObjectType )
864 executeDispatch_EditText();
865 else
866 executeDispatch_ObjectProperties();
869 void ChartController::execute_Resize()
871 m_pChartWindow->Invalidate();
873 void ChartController::execute_Activate()
875 ///// pDrawViewWrapper->SetEditMode(TRUE);
877 void ChartController::execute_Deactivate()
880 pDrawViewWrapper->SetEditMode(FALSE);
881 this->ReleaseMouse();
884 void ChartController::execute_GetFocus()
887 void ChartController::execute_LoseFocus()
889 //this->ReleaseMouse();
892 void ChartController::execute_Command( const CommandEvent& rCEvt )
894 Window* pWindow = m_pChartWindow;
896 bool bIsAction = false;
898 ::vos::OGuard aGuard( Application::GetSolarMutex());
899 DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper;
900 if(!pWindow || !pDrawViewWrapper)
901 return;
902 bIsAction = m_pDrawViewWrapper->IsAction();
905 // pop-up menu
906 if(rCEvt.GetCommand() == COMMAND_CONTEXTMENU && !bIsAction)
908 m_pChartWindow->ReleaseMouse();
910 if( m_aSelection.isSelectionDifferentFromBeforeMouseDown() )
911 impl_notifySelectionChangeListeners();
913 // todo: the context menu should be specified by an xml file in uiconfig
914 uno::Reference< awt::XPopupMenu > xPopupMenu(
915 m_xCC->getServiceManager()->createInstanceWithContext(
916 C2U("com.sun.star.awt.PopupMenu"), m_xCC ), uno::UNO_QUERY );
917 uno::Reference< awt::XMenuExtended > xMenuEx( xPopupMenu, uno::UNO_QUERY );
918 if( xPopupMenu.is() && xMenuEx.is())
920 sal_Int16 nUniqueId = 1;
921 ObjectType eObjectType = ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() );
922 Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( m_aModel->getModel() );
924 OUString aFormatCommand( lcl_getFormatCommandForObjectCID( m_aSelection.getSelectedCID() ) );
925 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, aFormatCommand );
927 //some commands for dataseries and points:
928 //-----
929 if( OBJECTTYPE_DATA_SERIES == eObjectType || OBJECTTYPE_DATA_POINT == eObjectType )
931 bool bIsPoint = ( OBJECTTYPE_DATA_POINT == eObjectType );
932 uno::Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel() );
933 uno::Reference< chart2::XRegressionCurveContainer > xCurveCnt( xSeries, uno::UNO_QUERY );
934 Reference< chart2::XRegressionCurve > xTrendline( RegressionCurveHelper::getFirstCurveNotMeanValueLine( xCurveCnt ) );
935 bool bHasEquation = RegressionCurveHelper::hasEquation( xTrendline );
936 Reference< chart2::XRegressionCurve > xMeanValue( RegressionCurveHelper::getMeanValueLine( xCurveCnt ) );
937 bool bHasYErrorBars = StatisticsHelper::hasErrorBars( xSeries, true );
938 bool bHasDataLabelsAtSeries = DataSeriesHelper::hasDataLabelsAtSeries( xSeries );
939 bool bHasDataLabelsAtPoints = DataSeriesHelper::hasDataLabelsAtPoints( xSeries );
940 bool bHasDataLabelAtPoint = false;
941 sal_Int32 nPointIndex = -1;
942 if( bIsPoint )
944 nPointIndex = ObjectIdentifier::getIndexFromParticleOrCID( m_aSelection.getSelectedCID() );
945 bHasDataLabelAtPoint = DataSeriesHelper::hasDataLabelAtPoint( xSeries, nPointIndex );
947 bool bSelectedPointIsFormatted = false;
948 bool bHasFormattedDataPointsOtherThanSelected = false;
950 Reference< beans::XPropertySet > xSeriesProperties( xSeries, uno::UNO_QUERY );
951 if( xSeriesProperties.is() )
953 uno::Sequence< sal_Int32 > aAttributedDataPointIndexList;
954 if( xSeriesProperties->getPropertyValue( C2U( "AttributedDataPoints" ) ) >>= aAttributedDataPointIndexList )
956 if( aAttributedDataPointIndexList.hasElements() )
958 if( bIsPoint )
960 ::std::vector< sal_Int32 > aIndices( ContainerHelper::SequenceToVector( aAttributedDataPointIndexList ) );
961 ::std::vector< sal_Int32 >::iterator aIt = ::std::find( aIndices.begin(), aIndices.end(), nPointIndex );
962 if( aIt != aIndices.end())
963 bSelectedPointIsFormatted = true;
964 else
965 bHasFormattedDataPointsOtherThanSelected = true;
967 else
968 bHasFormattedDataPointsOtherThanSelected = true;
973 //const sal_Int32 nIdBeforeFormat = nUniqueId;
974 if( bIsPoint )
976 if( bHasDataLabelAtPoint )
977 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatDataLabel") );
978 if( !bHasDataLabelAtPoint )
979 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertDataLabel") );
980 else
981 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteDataLabel") );
982 if( bSelectedPointIsFormatted )
983 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:ResetDataPoint"));
985 xPopupMenu->insertSeparator( -1 );
987 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatDataSeries") );
990 Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) );
991 if( xChartType->getChartType().equals(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
995 Reference< beans::XPropertySet > xChartTypeProp( xChartType, uno::UNO_QUERY );
996 if( xChartTypeProp.is() )
998 bool bJapaneseStyle = false;
999 xChartTypeProp->getPropertyValue( C2U( "Japanese" ) ) >>= bJapaneseStyle;
1001 if( bJapaneseStyle )
1003 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatStockLoss") );
1004 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatStockGain") );
1008 catch( const uno::Exception & ex )
1010 ASSERT_EXCEPTION( ex );
1014 if( bHasDataLabelsAtSeries )
1015 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatDataLabels") );
1016 if( xTrendline.is() )
1017 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatTrendline") );
1018 if( bHasEquation )
1019 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatTrendlineEquation") );
1020 if( xMeanValue.is() )
1021 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatMeanValue") );
1022 if( bHasYErrorBars )
1023 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatYErrorBars") );
1025 //if( nIdBeforeFormat != nUniqueId )
1026 xPopupMenu->insertSeparator( -1 );
1028 //const sal_Int32 nIdBeforeInsert = nUniqueId;
1030 if( !bHasDataLabelsAtSeries )
1031 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertDataLabels") );
1032 if( !xTrendline.is() )
1033 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertTrendline") );
1034 else if( !bHasEquation )
1035 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertTrendlineEquation") );
1036 if( !xMeanValue.is() )
1037 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertMeanValue") );
1038 if( !bHasYErrorBars )
1039 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertYErrorBars") );
1041 //if( nIdBeforeInsert != nUniqueId )
1042 // xPopupMenu->insertSeparator( -1 );
1044 //const sal_Int32 nIdBeforeDelete = nUniqueId;
1046 if( bHasDataLabelsAtSeries || ( bHasDataLabelsAtPoints && bHasFormattedDataPointsOtherThanSelected ) )
1047 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteDataLabels") );
1048 if( xTrendline.is() )
1049 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteTrendline") );
1050 if( bHasEquation )
1051 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteTrendlineEquation") );
1052 if( xMeanValue.is() )
1053 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteMeanValue") );
1054 if( bHasYErrorBars )
1055 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteYErrorBars") );
1057 if( bHasFormattedDataPointsOtherThanSelected )
1058 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:ResetAllDataPoints"));
1060 //if( nIdBeforeDelete != nUniqueId )
1061 xPopupMenu->insertSeparator( -1 );
1063 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId, C2U(".uno:ArrangeRow"));
1064 uno::Reference< awt::XPopupMenu > xArrangePopupMenu(
1065 m_xCC->getServiceManager()->createInstanceWithContext(
1066 C2U("com.sun.star.awt.PopupMenu"), m_xCC ), uno::UNO_QUERY );
1067 uno::Reference< awt::XMenuExtended > xArrangeMenuEx( xArrangePopupMenu, uno::UNO_QUERY );
1068 if( xArrangePopupMenu.is() && xArrangeMenuEx.is())
1070 sal_Int16 nSubId = nUniqueId + 1;
1071 lcl_insertMenuCommand( xArrangePopupMenu, xArrangeMenuEx, nSubId++, C2U(".uno:Forward") );
1072 lcl_insertMenuCommand( xArrangePopupMenu, xArrangeMenuEx, nSubId, C2U(".uno:Backward") );
1073 xPopupMenu->setPopupMenu( nUniqueId, xArrangePopupMenu );
1074 nUniqueId = nSubId;
1076 ++nUniqueId;
1078 else if( OBJECTTYPE_DATA_CURVE == eObjectType )
1080 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatTrendlineEquation") );
1081 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertTrendlineEquation") );
1082 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertTrendlineEquationAndR2") );
1083 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertR2Value") );
1084 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteTrendlineEquation") );
1085 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteR2Value") );
1087 else if( OBJECTTYPE_DATA_CURVE_EQUATION == eObjectType )
1089 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertR2Value") );
1090 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteR2Value") );
1093 //some commands for axes: and grids
1094 //-----
1095 else if( OBJECTTYPE_AXIS == eObjectType || OBJECTTYPE_GRID == eObjectType || OBJECTTYPE_SUBGRID == eObjectType )
1097 Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), m_aModel->getModel() );
1098 if( xAxis.is() && xDiagram.is() )
1100 sal_Int32 nDimensionIndex = -1;
1101 sal_Int32 nCooSysIndex = -1;
1102 sal_Int32 nAxisIndex = -1;
1103 AxisHelper::getIndicesForAxis( xAxis, xDiagram, nCooSysIndex, nDimensionIndex, nAxisIndex );
1104 bool bIsSecondaryAxis = nAxisIndex!=0;
1105 bool bIsAxisVisible = AxisHelper::isAxisVisible( xAxis );
1106 bool bIsMajorGridVisible = AxisHelper::isGridShown( nDimensionIndex, nCooSysIndex, true /*bMainGrid*/, xDiagram );
1107 bool bIsMinorGridVisible = AxisHelper::isGridShown( nDimensionIndex, nCooSysIndex, false /*bMainGrid*/, xDiagram );
1108 bool bHasTitle = false;
1109 uno::Reference< XTitled > xTitled( xAxis, uno::UNO_QUERY );
1110 if( xTitled.is())
1111 bHasTitle = TitleHelper::getCompleteString( xTitled->getTitleObject() ).getLength()>0;
1113 if( OBJECTTYPE_AXIS != eObjectType && bIsAxisVisible )
1114 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatAxis") );
1115 if( OBJECTTYPE_GRID != eObjectType && bIsMajorGridVisible && !bIsSecondaryAxis )
1116 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatMajorGrid") );
1117 if( OBJECTTYPE_SUBGRID != eObjectType && bIsMinorGridVisible && !bIsSecondaryAxis )
1118 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatMinorGrid") );
1120 xPopupMenu->insertSeparator( -1 );
1122 if( OBJECTTYPE_AXIS != eObjectType && !bIsAxisVisible )
1123 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertAxis") );
1124 if( OBJECTTYPE_GRID != eObjectType && !bIsMajorGridVisible && !bIsSecondaryAxis )
1125 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertMajorGrid") );
1126 if( OBJECTTYPE_SUBGRID != eObjectType && !bIsMinorGridVisible && !bIsSecondaryAxis )
1127 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertMinorGrid") );
1128 if( !bHasTitle )
1129 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertAxisTitle") );
1131 if( bIsAxisVisible )
1132 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteAxis") );
1133 if( bIsMajorGridVisible && !bIsSecondaryAxis )
1134 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteMajorGrid") );
1135 if( bIsMinorGridVisible && !bIsSecondaryAxis )
1136 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteMinorGrid") );
1140 if( OBJECTTYPE_DATA_STOCK_LOSS == eObjectType )
1141 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatStockGain") );
1142 else if( OBJECTTYPE_DATA_STOCK_GAIN == eObjectType )
1143 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatStockLoss") );
1145 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:TransformDialog"));
1147 if( OBJECTTYPE_PAGE == eObjectType || OBJECTTYPE_DIAGRAM == eObjectType
1148 || OBJECTTYPE_DIAGRAM_WALL == eObjectType
1149 || OBJECTTYPE_DIAGRAM_FLOOR == eObjectType
1150 || OBJECTTYPE_UNKNOWN == eObjectType )
1152 if( OBJECTTYPE_UNKNOWN != eObjectType )
1153 xPopupMenu->insertSeparator( -1 );
1154 bool bHasLegend = LegendHelper::hasLegend( xDiagram );
1155 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertTitles") );
1156 if( !bHasLegend )
1157 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertLegend") );
1158 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertRemoveAxes") );
1159 if( bHasLegend )
1160 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteLegend") );
1162 //-----
1164 xPopupMenu->insertSeparator( -1 );
1165 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DiagramType"));
1166 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DataRanges"));
1167 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DiagramData"));
1168 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:View3D"));
1169 xPopupMenu->insertSeparator( -1 );
1170 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:Cut"));
1171 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:Copy"));
1172 lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:Paste"));
1174 ::svt::ContextMenuHelper aContextMenuHelper( m_xFrame );
1175 Point aPos( rCEvt.GetMousePosPixel() );
1176 if( !rCEvt.IsMouseEvent() )
1177 aPos = m_pChartWindow->GetPointerState().maPos;
1178 aContextMenuHelper.completeAndExecute( aPos, xPopupMenu );
1181 else if( ( rCEvt.GetCommand() == COMMAND_STARTEXTTEXTINPUT ) ||
1182 ( rCEvt.GetCommand() == COMMAND_EXTTEXTINPUT ) ||
1183 ( rCEvt.GetCommand() == COMMAND_ENDEXTTEXTINPUT ) ||
1184 ( rCEvt.GetCommand() == COMMAND_INPUTCONTEXTCHANGE ) )
1186 //#i84417# enable editing with IME
1187 if( m_pDrawViewWrapper )
1188 m_pDrawViewWrapper->Command( rCEvt, m_pChartWindow );
1192 bool ChartController::execute_KeyInput( const KeyEvent& rKEvt )
1194 bool bReturn=false;
1196 Window* pWindow = m_pChartWindow;
1197 DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper;
1198 if(!pWindow || !pDrawViewWrapper)
1199 return bReturn;
1201 // handle accelerators
1202 if( ! m_apAccelExecute.get() && m_xFrame.is() && m_xCC.is() && m_xCC->getServiceManager().is() )
1204 m_apAccelExecute.reset( ::svt::AcceleratorExecute::createAcceleratorHelper());
1205 OSL_ASSERT( m_apAccelExecute.get());
1206 if( m_apAccelExecute.get() )
1207 m_apAccelExecute->init(
1208 uno::Reference< lang::XMultiServiceFactory >( m_xCC->getServiceManager(), uno::UNO_QUERY ), m_xFrame );
1211 KeyCode aKeyCode( rKEvt.GetKeyCode());
1212 sal_uInt16 nCode = aKeyCode.GetCode();
1213 // bool bShift = aKeyCode.IsShift();
1214 bool bAlternate = aKeyCode.IsMod2();
1216 if( m_apAccelExecute.get() )
1217 bReturn = m_apAccelExecute->execute( aKeyCode );
1218 if( bReturn )
1219 return bReturn;
1221 if( pDrawViewWrapper->IsTextEdit() )
1223 if( pDrawViewWrapper->KeyInput(rKEvt,pWindow) )
1225 bReturn = true;
1226 if( nCode == KEY_ESCAPE )
1228 this->EndTextEdit();
1233 //if( m_pDrawViewWrapper->IsAction() );
1235 // keyboard accessibility
1236 ObjectType eObjectType = ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() );
1237 if( ! bReturn )
1239 // Natvigation (Tab/F3/Home/End)
1240 uno::Reference< XChartDocument > xChartDoc( m_aModel->getModel(), uno::UNO_QUERY );
1241 ObjectKeyNavigation aObjNav( m_aSelection.getSelectedCID(), xChartDoc, ExplicitValueProvider::getExplicitValueProvider( m_xChartView ));
1242 awt::KeyEvent aKeyEvent( ::svt::AcceleratorExecute::st_VCLKey2AWTKey( aKeyCode ));
1243 bReturn = aObjNav.handleKeyEvent( aKeyEvent );
1244 if( bReturn )
1246 ::rtl::OUString aNewCID = aObjNav.getCurrentSelection();
1247 uno::Any aNewSelection;
1248 if( aNewCID.getLength()>0 && !ObjectHierarchy::isRootNode( aNewCID ))
1249 aNewSelection <<= aNewCID;
1250 if( m_eDragMode == SDRDRAG_ROTATE && !SelectionHelper::isRotateableObject( aNewCID, m_aModel->getModel() ) )
1251 m_eDragMode = SDRDRAG_MOVE;
1252 bReturn = select( aNewSelection );
1256 // Position and Size (+/-/arrow-keys) or pie segment dragging
1257 if( ! bReturn )
1259 // pie segment dragging
1260 // note: could also be done for data series
1261 if( eObjectType == OBJECTTYPE_DATA_POINT &&
1262 ObjectIdentifier::getDragMethodServiceName( m_aSelection.getSelectedCID() ).equals(
1263 ObjectIdentifier::getPieSegmentDragMethodServiceName()))
1265 bool bDrag = false;
1266 bool bDragInside = false;
1267 if( nCode == KEY_ADD ||
1268 nCode == KEY_SUBTRACT )
1270 bDrag = true;
1271 bDragInside = ( nCode == KEY_SUBTRACT );
1273 else if(
1274 nCode == KEY_LEFT ||
1275 nCode == KEY_RIGHT ||
1276 nCode == KEY_UP ||
1277 nCode == KEY_DOWN )
1279 bDrag = true;
1280 rtl::OUString aParameter( ObjectIdentifier::getDragParameterString( m_aSelection.getSelectedCID() ));
1281 sal_Int32 nOffsetPercentDummy( 0 );
1282 awt::Point aMinimumPosition( 0, 0 );
1283 awt::Point aMaximumPosition( 0, 0 );
1284 ObjectIdentifier::parsePieSegmentDragParameterString(
1285 aParameter, nOffsetPercentDummy, aMinimumPosition, aMaximumPosition );
1286 aMaximumPosition.Y -= aMinimumPosition.Y;
1287 aMaximumPosition.X -= aMinimumPosition.X;
1289 bDragInside =
1290 (nCode == KEY_RIGHT && (aMaximumPosition.X < 0)) ||
1291 (nCode == KEY_LEFT && (aMaximumPosition.X > 0)) ||
1292 (nCode == KEY_DOWN && (aMaximumPosition.Y < 0)) ||
1293 (nCode == KEY_UP && (aMaximumPosition.Y > 0));
1296 if( bDrag )
1298 double fAmount = bAlternate ? 0.01 : 0.05;
1299 if( bDragInside )
1300 fAmount *= -1.0;
1302 bReturn = impl_DragDataPoint( m_aSelection.getSelectedCID(), fAmount );
1305 else
1307 // size
1308 if( nCode == KEY_ADD ||
1309 nCode == KEY_SUBTRACT )
1311 if( eObjectType == OBJECTTYPE_DIAGRAM )
1313 // default 1 mm in each direction
1314 double fGrowAmountX = 200.0;
1315 double fGrowAmountY = 200.0;
1316 if( bAlternate && pWindow )
1318 // together with Alt-key: 1 px in each direction
1319 Size aPixelSize = pWindow->PixelToLogic( Size( 2, 2 ));
1320 fGrowAmountX = static_cast< double >( aPixelSize.Width());
1321 fGrowAmountY = static_cast< double >( aPixelSize.Height());
1323 if( nCode == KEY_SUBTRACT )
1325 fGrowAmountX = -fGrowAmountX;
1326 fGrowAmountY = -fGrowAmountY;
1328 bReturn = impl_moveOrResizeObject(
1329 m_aSelection.getSelectedCID(), CENTERED_RESIZE_OBJECT, fGrowAmountX, fGrowAmountY );
1332 // position
1333 else if( nCode == KEY_LEFT ||
1334 nCode == KEY_RIGHT ||
1335 nCode == KEY_UP ||
1336 nCode == KEY_DOWN )
1338 if( m_aSelection.isDragableObjectSelected() )
1340 // default 1 mm
1341 double fShiftAmountX = 100.0;
1342 double fShiftAmountY = 100.0;
1343 if( bAlternate && pWindow )
1345 // together with Alt-key: 1 px
1346 Size aPixelSize = pWindow->PixelToLogic( Size( 1, 1 ));
1347 fShiftAmountX = static_cast< double >( aPixelSize.Width());
1348 fShiftAmountY = static_cast< double >( aPixelSize.Height());
1350 switch( nCode )
1352 case KEY_LEFT:
1353 fShiftAmountX = -fShiftAmountX;
1354 fShiftAmountY = 0.0;
1355 break;
1356 case KEY_RIGHT:
1357 fShiftAmountY = 0.0;
1358 break;
1359 case KEY_UP:
1360 fShiftAmountX = 0.0;
1361 fShiftAmountY = -fShiftAmountY;
1362 break;
1363 case KEY_DOWN:
1364 fShiftAmountX = 0.0;
1365 break;
1367 if( m_aSelection.getSelectedCID().getLength() )
1369 //move chart objects
1370 bReturn = impl_moveOrResizeObject(
1371 m_aSelection.getSelectedCID(), MOVE_OBJECT, fShiftAmountX, fShiftAmountY );
1373 else
1375 //move additional shapes
1376 uno::Reference< drawing::XShape > xShape( m_aSelection.getSelectedAdditionalShape() );
1377 if( xShape.is() )
1379 awt::Point aPos( xShape->getPosition() );
1380 awt::Size aSize( xShape->getSize() );
1381 awt::Size aPageSize( ChartModelHelper::getPageSize( m_aModel->getModel() ) );
1382 aPos.X = static_cast< long >( static_cast< double >( aPos.X ) + fShiftAmountX );
1383 aPos.Y = static_cast< long >( static_cast< double >( aPos.Y ) + fShiftAmountY );
1384 if( aPos.X + aSize.Width > aPageSize.Width )
1385 aPos.X = aPageSize.Width - aSize.Width;
1386 if( aPos.X < 0 )
1387 aPos.X = 0;
1388 if( aPos.Y + aSize.Height > aPageSize.Height )
1389 aPos.Y = aPageSize.Height - aSize.Height;
1390 if( aPos.Y < 0 )
1391 aPos.Y = 0;
1393 xShape->setPosition( aPos );
1401 // text edit
1402 if( ! bReturn &&
1403 nCode == KEY_F2 )
1405 if( OBJECTTYPE_TITLE == eObjectType )
1407 executeDispatch_EditText();
1408 bReturn = true;
1412 // deactivate inplace mode (this code should be unnecessary, but
1413 // unfortunately is not)
1414 if( ! bReturn &&
1415 nCode == KEY_ESCAPE )
1417 uno::Reference< frame::XDispatchHelper > xDispatchHelper(
1418 m_xCC->getServiceManager()->createInstanceWithContext(
1419 C2U("com.sun.star.frame.DispatchHelper"), m_xCC ), uno::UNO_QUERY );
1420 if( xDispatchHelper.is())
1422 uno::Sequence< beans::PropertyValue > aArgs;
1423 xDispatchHelper->executeDispatch(
1424 uno::Reference< frame::XDispatchProvider >( m_xFrame, uno::UNO_QUERY ),
1425 C2U(".uno:TerminateInplaceActivation"),
1426 C2U("_parent"),
1427 frame::FrameSearchFlag::PARENT,
1428 aArgs );
1429 bReturn = true;
1433 if( ! bReturn &&
1434 (nCode == KEY_DELETE || nCode == KEY_BACKSPACE ))
1436 bReturn = executeDispatch_Delete();
1437 if( ! bReturn )
1439 InfoBox( m_pChartWindow, String(SchResId( STR_ACTION_NOTPOSSIBLE ))).Execute();
1443 /* old chart:
1444 // Ctrl-Shift-R: Repaint
1445 if (!bReturn && GetWindow())
1447 KeyCode aKeyCode = rKEvt.GetKeyCode();
1449 if (aKeyCode.IsMod1() && aKeyCode.IsShift()
1450 && aKeyCode.GetCode() == KEY_R)
1452 // 3D-Kontext wieder zerstoeren
1453 GetWindow()->Invalidate();
1454 bReturn = TRUE;
1458 return bReturn;
1461 bool ChartController::requestQuickHelp(
1462 ::Point aAtLogicPosition,
1463 bool bIsBalloonHelp,
1464 ::rtl::OUString & rOutQuickHelpText,
1465 awt::Rectangle & rOutEqualRect )
1467 uno::Reference< frame::XModel > xChartModel;
1468 if( m_aModel.is())
1469 xChartModel.set( m_aModel->getModel());
1470 if( !xChartModel.is())
1471 return false;
1473 // help text
1474 ::rtl::OUString aCID;
1475 if( m_pDrawViewWrapper )
1477 aCID = SelectionHelper::getHitObjectCID(
1478 aAtLogicPosition, *m_pDrawViewWrapper );
1480 bool bResult( aCID.getLength());
1482 if( bResult )
1484 // get help text
1485 rOutQuickHelpText = ObjectNameProvider::getHelpText( aCID, xChartModel, bIsBalloonHelp /* bVerbose */ );
1487 // set rectangle
1488 ExplicitValueProvider * pValueProvider(
1489 ExplicitValueProvider::getExplicitValueProvider( m_xChartView ));
1490 if( pValueProvider )
1491 rOutEqualRect = pValueProvider->getRectangleOfObject( aCID, true );
1494 return bResult;
1497 //-----------------------------------------------------------------
1498 // XSelectionSupplier (optional interface)
1499 //-----------------------------------------------------------------
1500 sal_Bool SAL_CALL ChartController
1501 ::select( const uno::Any& rSelection )
1502 throw( lang::IllegalArgumentException )
1504 rtl::OUString aNewCID;
1505 if( rSelection.hasValue() &&
1506 ! (rSelection >>= aNewCID))
1507 return sal_False;
1510 if( m_aSelection.setSelection( aNewCID ) )
1512 this->impl_selectObjectAndNotiy();
1513 return sal_True;
1515 return sal_False;
1518 uno::Any SAL_CALL ChartController
1519 ::getSelection() throw(uno::RuntimeException)
1521 return uno::makeAny(m_aSelection.getSelectedCID());
1524 void SAL_CALL ChartController
1525 ::addSelectionChangeListener( const uno::Reference<
1526 view::XSelectionChangeListener > & xListener )
1527 throw(uno::RuntimeException)
1529 ::vos::OGuard aGuard( Application::GetSolarMutex());
1530 if( impl_isDisposedOrSuspended() )//@todo? allow adding of listeners in suspend mode?
1531 return; //behave passive if already disposed or suspended
1533 //--add listener
1534 m_aLifeTimeManager.m_aListenerContainer.addInterface( ::getCppuType((const uno::Reference< view::XSelectionChangeListener >*)0), xListener );
1537 void SAL_CALL ChartController
1538 ::removeSelectionChangeListener( const uno::Reference<
1539 view::XSelectionChangeListener > & xListener )
1540 throw(uno::RuntimeException)
1542 ::vos::OGuard aGuard( Application::GetSolarMutex());
1543 if( impl_isDisposedOrSuspended() ) //@todo? allow removing of listeners in suspend mode?
1544 return; //behave passive if already disposed or suspended
1546 //--remove listener
1547 m_aLifeTimeManager.m_aListenerContainer.removeInterface( ::getCppuType((const uno::Reference< view::XSelectionChangeListener >*)0), xListener );
1550 void ChartController
1551 ::impl_notifySelectionChangeListeners()
1553 ::cppu::OInterfaceContainerHelper* pIC = m_aLifeTimeManager.m_aListenerContainer
1554 .getContainer( ::getCppuType((const uno::Reference< view::XSelectionChangeListener >*)0) );
1555 if( pIC )
1557 uno::Reference< view::XSelectionSupplier > xSelectionSupplier(this);
1558 lang::EventObject aEvent( xSelectionSupplier );
1559 ::cppu::OInterfaceIteratorHelper aIt( *pIC );
1560 while( aIt.hasMoreElements() )
1561 (static_cast< view::XSelectionChangeListener*>(aIt.next()))->selectionChanged( aEvent );
1565 void ChartController::impl_selectObjectAndNotiy()
1567 DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper;
1568 if( pDrawViewWrapper )
1570 pDrawViewWrapper->SetDragMode( m_eDragMode );
1571 m_aSelection.applySelection( m_pDrawViewWrapper );
1573 impl_notifySelectionChangeListeners();
1576 bool ChartController::impl_moveOrResizeObject(
1577 const ::rtl::OUString & rCID,
1578 eMoveOrResizeType eType,
1579 double fAmountLogicX,
1580 double fAmountLogicY )
1582 bool bResult = false;
1583 bool bNeedShift = true;
1584 bool bNeedResize = ( eType == CENTERED_RESIZE_OBJECT );
1586 uno::Reference< frame::XModel > xChartModel( m_aModel->getModel());
1587 uno::Reference< beans::XPropertySet > xObjProp(
1588 ObjectIdentifier::getObjectPropertySet( rCID, xChartModel ));
1589 if( xObjProp.is())
1591 awt::Size aRefSize = ChartModelHelper::getPageSize( xChartModel );
1593 chart2::RelativePosition aRelPos;
1594 chart2::RelativeSize aRelSize;
1595 bool bDeterminePos = !(xObjProp->getPropertyValue( C2U("RelativePosition")) >>= aRelPos);
1596 bool bDetermineSize = !bNeedResize || !(xObjProp->getPropertyValue( C2U("RelativeSize")) >>= aRelSize);
1598 if( ( bDeterminePos || bDetermineSize ) &&
1599 ( aRefSize.Width > 0 && aRefSize.Height > 0 ) )
1601 ExplicitValueProvider * pValueProvider(
1602 ExplicitValueProvider::getExplicitValueProvider( m_xChartView ));
1603 if( pValueProvider )
1605 awt::Rectangle aRect( pValueProvider->getRectangleOfObject( rCID ));
1606 double fWidth = static_cast< double >( aRefSize.Width );
1607 double fHeight = static_cast< double >( aRefSize.Height );
1608 if( bDetermineSize )
1610 aRelSize.Primary = static_cast< double >( aRect.Width ) / fWidth;
1611 aRelSize.Secondary = static_cast< double >( aRect.Height ) / fHeight;
1613 if( bDeterminePos )
1615 if( bNeedResize && aRelSize.Primary > 0.0 && aRelSize.Secondary > 0.0 )
1617 aRelPos.Primary = (static_cast< double >( aRect.X ) / fWidth) +
1618 (aRelSize.Primary / 2.0);
1619 aRelPos.Secondary = (static_cast< double >( aRect.Y ) / fHeight) +
1620 (aRelSize.Secondary / 2.0);
1621 aRelPos.Anchor = drawing::Alignment_CENTER;
1623 else
1625 aRelPos.Primary = static_cast< double >( aRect.X ) / fWidth;
1626 aRelPos.Secondary = static_cast< double >( aRect.Y ) / fHeight;
1627 aRelPos.Anchor = drawing::Alignment_TOP_LEFT;
1633 if( eType == CENTERED_RESIZE_OBJECT )
1634 bResult = lcl_GrowAndShiftLogic( aRelPos, aRelSize, aRefSize, fAmountLogicX, fAmountLogicY );
1635 else if( eType == MOVE_OBJECT )
1636 bResult = lcl_MoveObjectLogic( aRelPos, aRelSize, aRefSize, fAmountLogicX, fAmountLogicY );
1638 if( bResult )
1640 ActionDescriptionProvider::ActionType eActionType(ActionDescriptionProvider::MOVE);
1641 if( bNeedResize )
1642 eActionType = ActionDescriptionProvider::RESIZE;
1644 ObjectType eObjectType = ObjectIdentifier::getObjectType( rCID );
1645 UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription(
1646 eActionType, ObjectNameProvider::getName( eObjectType )), m_xUndoManager, xChartModel );
1648 ControllerLockGuard aCLGuard( xChartModel );
1649 if( bNeedShift )
1650 xObjProp->setPropertyValue( C2U("RelativePosition"), uno::makeAny( aRelPos ));
1651 if( bNeedResize || (eObjectType == OBJECTTYPE_DIAGRAM) )//Also set an explicat size at the diagram when an explicit position is set
1652 xObjProp->setPropertyValue( C2U("RelativeSize"), uno::makeAny( aRelSize ));
1654 aUndoGuard.commitAction();
1657 return bResult;
1660 bool ChartController::impl_DragDataPoint( const ::rtl::OUString & rCID, double fAdditionalOffset )
1662 bool bResult = false;
1663 if( fAdditionalOffset < -1.0 || fAdditionalOffset > 1.0 || fAdditionalOffset == 0.0 )
1664 return bResult;
1666 sal_Int32 nDataPointIndex = ObjectIdentifier::getIndexFromParticleOrCID( rCID );
1667 uno::Reference< chart2::XDataSeries > xSeries(
1668 ObjectIdentifier::getDataSeriesForCID( rCID, m_aModel->getModel()));
1669 if( xSeries.is())
1673 uno::Reference< beans::XPropertySet > xPointProp( xSeries->getDataPointByIndex( nDataPointIndex ));
1674 double fOffset = 0.0;
1675 if( xPointProp.is() &&
1676 (xPointProp->getPropertyValue( C2U("Offset" )) >>= fOffset ) &&
1677 (( fAdditionalOffset > 0.0 && fOffset < 1.0 ) || (fOffset > 0.0)) )
1679 fOffset += fAdditionalOffset;
1680 if( fOffset > 1.0 )
1681 fOffset = 1.0;
1682 else if( fOffset < 0.0 )
1683 fOffset = 0.0;
1684 xPointProp->setPropertyValue( C2U("Offset"), uno::makeAny( fOffset ));
1685 bResult = true;
1688 catch( const uno::Exception & ex )
1690 ASSERT_EXCEPTION( ex );
1694 return bResult;
1697 void ChartController::impl_SetMousePointer( const MouseEvent & rEvent )
1699 ::vos::OGuard aGuard( Application::GetSolarMutex());
1700 Window* pWindow = m_pChartWindow;
1701 if( m_pDrawViewWrapper && pWindow )
1703 Point aMousePos( pWindow->PixelToLogic( rEvent.GetPosPixel()));
1704 sal_uInt16 nModifier = rEvent.GetModifier();
1705 BOOL bLeftDown = rEvent.IsLeft();
1707 if( m_pDrawViewWrapper->IsTextEdit() )
1709 if( m_pDrawViewWrapper->IsTextEditHit( aMousePos, HITPIX) )
1711 pWindow->SetPointer( m_pDrawViewWrapper->GetPreferedPointer(
1712 aMousePos, pWindow, nModifier, bLeftDown ) );
1713 return;
1716 else if( m_pDrawViewWrapper->IsAction() )
1718 return;//don't change pointer during running action
1721 SdrHdl* pHitSelectionHdl = 0;
1722 if( m_aSelection.isResizeableObjectSelected() )
1723 pHitSelectionHdl = m_pDrawViewWrapper->PickHandle( aMousePos );
1725 if( pHitSelectionHdl )
1728 Pointer aPointer = m_pDrawViewWrapper->GetPreferedPointer(
1729 aMousePos, pWindow, nModifier, bLeftDown );
1730 bool bForceArrowPointer = false;
1732 ::rtl::OUString aObjectCID = m_aSelection.getSelectedCID();
1734 switch( aPointer.GetStyle())
1736 case POINTER_NSIZE:
1737 case POINTER_SSIZE:
1738 case POINTER_WSIZE:
1739 case POINTER_ESIZE:
1740 case POINTER_NWSIZE:
1741 case POINTER_NESIZE:
1742 case POINTER_SWSIZE:
1743 case POINTER_SESIZE:
1744 if( ! m_aSelection.isResizeableObjectSelected() )
1745 bForceArrowPointer = true;
1746 break;
1747 case POINTER_MOVE:
1748 if( ! ObjectIdentifier::isDragableObject( aObjectCID ))
1749 bForceArrowPointer = true;
1750 break;
1751 case POINTER_MOVEPOINT:
1752 case POINTER_MOVEBEZIERWEIGHT:
1753 // there is no point-editing in a chart
1754 // the POINTER_MOVEBEZIERWEIGHT appears in 3d data points
1755 bForceArrowPointer = true;
1756 break;
1757 default:
1758 break;
1761 if( bForceArrowPointer )
1762 pWindow->SetPointer( Pointer( POINTER_ARROW ));
1763 else
1764 pWindow->SetPointer( aPointer );
1766 else
1768 ::rtl::OUString aHitObjectCID(
1769 SelectionHelper::getHitObjectCID(
1770 aMousePos, *m_pDrawViewWrapper, true /*bGetDiagramInsteadOf_Wall*/ ));
1772 if( m_pDrawViewWrapper->IsTextEdit() )
1774 if( aHitObjectCID.equals(m_aSelection.getSelectedCID()) )
1776 pWindow->SetPointer( Pointer( POINTER_ARROW ));
1777 return;
1781 if( !aHitObjectCID.getLength() )
1783 //additional shape was hit
1784 pWindow->SetPointer( POINTER_MOVE );
1786 else if( ObjectIdentifier::isDragableObject( aHitObjectCID ) )
1788 if( (m_eDragMode == SDRDRAG_ROTATE)
1789 && SelectionHelper::isRotateableObject( aHitObjectCID
1790 , m_aModel->getModel() ) )
1791 pWindow->SetPointer( Pointer( POINTER_ROTATE ) );
1792 else
1794 ObjectType eHitObjectType = ObjectIdentifier::getObjectType( aHitObjectCID );
1795 if( eHitObjectType == OBJECTTYPE_DATA_POINT )
1797 if( !ObjectIdentifier::areSiblings(aHitObjectCID,m_aSelection.getSelectedCID())
1798 && !ObjectIdentifier::areIdenticalObjects(aHitObjectCID,m_aSelection.getSelectedCID()) )
1800 pWindow->SetPointer( Pointer( POINTER_ARROW ));
1801 return;
1804 pWindow->SetPointer( POINTER_MOVE );
1807 else
1808 pWindow->SetPointer( Pointer( POINTER_ARROW ));
1813 //.............................................................................
1814 } //namespace chart
1815 //.............................................................................