LCOV - code coverage report
Current view: top level - chart2/source/controller/main - ChartController_Window.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 90 1040 8.7 %
Date: 2014-04-11 Functions: 11 50 22.0 %
Legend: Lines: hit not hit

          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 "PositionAndSizeHelper.hxx"
      22             : #include "ObjectIdentifier.hxx"
      23             : #include "ChartWindow.hxx"
      24             : #include "ResId.hxx"
      25             : #include "CommonConverters.hxx"
      26             : #include "ChartModelHelper.hxx"
      27             : #include "DiagramHelper.hxx"
      28             : #include "TitleHelper.hxx"
      29             : #include "UndoGuard.hxx"
      30             : #include "ControllerLockGuard.hxx"
      31             : #include "ObjectNameProvider.hxx"
      32             : #include "Strings.hrc"
      33             : #include "macros.hxx"
      34             : #include "DragMethod_PieSegment.hxx"
      35             : #include "DragMethod_RotateDiagram.hxx"
      36             : #include "ObjectHierarchy.hxx"
      37             : #include "chartview/ExplicitValueProvider.hxx"
      38             : #include "RelativePositionHelper.hxx"
      39             : #include "chartview/DrawModelWrapper.hxx"
      40             : #include "RegressionCurveHelper.hxx"
      41             : #include "StatisticsHelper.hxx"
      42             : #include "DataSeriesHelper.hxx"
      43             : #include "ContainerHelper.hxx"
      44             : #include "AxisHelper.hxx"
      45             : #include "LegendHelper.hxx"
      46             : #include "servicenames_charttypes.hxx"
      47             : #include "MenuResIds.hrc"
      48             : #include "DrawCommandDispatch.hxx"
      49             : 
      50             : #include <com/sun/star/chart2/RelativePosition.hpp>
      51             : #include <com/sun/star/chart2/RelativeSize.hpp>
      52             : #include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
      53             : 
      54             : #include <com/sun/star/frame/DispatchHelper.hpp>
      55             : #include <com/sun/star/frame/FrameSearchFlag.hpp>
      56             : #include <com/sun/star/util/XUpdatable.hpp>
      57             : #include <comphelper/InlineContainer.hxx>
      58             : 
      59             : #include <svtools/contextmenuhelper.hxx>
      60             : #include <toolkit/awt/vclxmenu.hxx>
      61             : 
      62             : #include <svx/svxids.hrc>
      63             : #include <svx/ActionDescriptionProvider.hxx>
      64             : 
      65             : // header for class E3dObject
      66             : #include <svx/obj3d.hxx>
      67             : // header for class E3dScene
      68             : #include <svx/scene3d.hxx>
      69             : // header for class SdrDragMethod
      70             : #include <svx/svddrgmt.hxx>
      71             : #include <vcl/svapp.hxx>
      72             : #include <vcl/settings.hxx>
      73             : #include <osl/mutex.hxx>
      74             : 
      75             : // for InfoBox
      76             : #include <vcl/msgbox.hxx>
      77             : 
      78             : #include <rtl/math.hxx>
      79             : #include <svtools/acceleratorexecute.hxx>
      80             : 
      81             : #define DRGPIX    2     // Drag MinMove in Pixel
      82             : 
      83             : using namespace ::com::sun::star;
      84             : using namespace ::com::sun::star::chart2;
      85             : using ::com::sun::star::uno::Reference;
      86             : 
      87             : namespace chart
      88             : {
      89             : 
      90             : namespace
      91             : {
      92           0 : bool lcl_GrowAndShiftLogic(
      93             :     RelativePosition &  rInOutRelPos,
      94             :     RelativeSize &      rInOutRelSize,
      95             :     const awt::Size &   rRefSize,
      96             :     double              fGrowLogicX,
      97             :     double              fGrowLogicY )
      98             : {
      99           0 :     if( rRefSize.Width == 0 ||
     100           0 :         rRefSize.Height == 0 )
     101           0 :         return false;
     102             : 
     103           0 :     double fRelativeGrowX = fGrowLogicX / rRefSize.Width;
     104           0 :     double fRelativeGrowY = fGrowLogicY / rRefSize.Height;
     105             : 
     106             :     return ::chart::RelativePositionHelper::centerGrow(
     107             :         rInOutRelPos, rInOutRelSize,
     108             :         fRelativeGrowX, fRelativeGrowY,
     109           0 :         /* bCheck = */ true );
     110             : }
     111             : 
     112           0 : bool lcl_MoveObjectLogic(
     113             :     RelativePosition &  rInOutRelPos,
     114             :     RelativeSize &      rObjectSize,
     115             :     const awt::Size &   rRefSize,
     116             :     double              fShiftLogicX,
     117             :     double              fShiftLogicY )
     118             : {
     119           0 :     if( rRefSize.Width == 0 ||
     120           0 :         rRefSize.Height == 0 )
     121           0 :         return false;
     122             : 
     123           0 :     double fRelativeShiftX = fShiftLogicX / rRefSize.Width;
     124           0 :     double fRelativeShiftY = fShiftLogicY / rRefSize.Height;
     125             : 
     126             :     return ::chart::RelativePositionHelper::moveObject(
     127             :         rInOutRelPos, rObjectSize,
     128             :         fRelativeShiftX, fRelativeShiftY,
     129           0 :         /* bCheck = */ true );
     130             : }
     131             : 
     132           0 : void lcl_insertMenuCommand(
     133             :     const uno::Reference< awt::XPopupMenu > & xMenu,
     134             :     sal_Int16 nId, const OUString & rCommand )
     135             : {
     136           0 :     static OUString aEmptyString;
     137           0 :     xMenu->insertItem( nId, aEmptyString, 0, -1 );
     138           0 :     xMenu->setCommand( nId, rCommand );
     139           0 : }
     140             : 
     141           0 : OUString lcl_getFormatCommandForObjectCID( const OUString& rCID )
     142             : {
     143           0 :     OUString aDispatchCommand( ".uno:FormatSelection" );
     144             : 
     145           0 :     ObjectType eObjectType = ObjectIdentifier::getObjectType( rCID );
     146             : 
     147           0 :     switch(eObjectType)
     148             :     {
     149             :         case OBJECTTYPE_DIAGRAM:
     150             :         case OBJECTTYPE_DIAGRAM_WALL:
     151           0 :             aDispatchCommand = ".uno:FormatWall";
     152           0 :             break;
     153             :         case OBJECTTYPE_DIAGRAM_FLOOR:
     154           0 :             aDispatchCommand = ".uno:FormatFloor";
     155           0 :             break;
     156             :         case OBJECTTYPE_PAGE:
     157           0 :             aDispatchCommand = ".uno:FormatChartArea";
     158           0 :             break;
     159             :         case OBJECTTYPE_LEGEND:
     160           0 :             aDispatchCommand = ".uno:FormatLegend";
     161           0 :             break;
     162             :         case OBJECTTYPE_TITLE:
     163           0 :             aDispatchCommand = ".uno:FormatTitle";
     164           0 :             break;
     165             :         case OBJECTTYPE_LEGEND_ENTRY:
     166           0 :             aDispatchCommand = ".uno:FormatDataSeries";
     167           0 :             break;
     168             :         case OBJECTTYPE_AXIS:
     169             :         case OBJECTTYPE_AXIS_UNITLABEL:
     170           0 :             aDispatchCommand = ".uno:FormatAxis";
     171           0 :             break;
     172             :         case OBJECTTYPE_GRID:
     173           0 :             aDispatchCommand = ".uno:FormatMajorGrid";
     174           0 :             break;
     175             :         case OBJECTTYPE_SUBGRID:
     176           0 :             aDispatchCommand = ".uno:FormatMinorGrid";
     177           0 :             break;
     178             :         case OBJECTTYPE_DATA_LABELS:
     179           0 :             aDispatchCommand = ".uno:FormatDataLabels";
     180           0 :             break;
     181             :         case OBJECTTYPE_DATA_SERIES:
     182           0 :             aDispatchCommand = ".uno:FormatDataSeries";
     183           0 :             break;
     184             :         case OBJECTTYPE_DATA_LABEL:
     185           0 :             aDispatchCommand = ".uno:FormatDataLabel";
     186           0 :             break;
     187             :         case OBJECTTYPE_DATA_POINT:
     188           0 :             aDispatchCommand = ".uno:FormatDataPoint";
     189           0 :             break;
     190             :         case OBJECTTYPE_DATA_AVERAGE_LINE:
     191           0 :             aDispatchCommand = ".uno:FormatMeanValue";
     192           0 :             break;
     193             :         case OBJECTTYPE_DATA_ERRORS_X:
     194           0 :             aDispatchCommand = ".uno:FormatXErrorBars";
     195           0 :             break;
     196             :         case OBJECTTYPE_DATA_ERRORS_Y:
     197           0 :             aDispatchCommand = ".uno:FormatYErrorBars";
     198           0 :             break;
     199             :         case OBJECTTYPE_DATA_ERRORS_Z:
     200           0 :             aDispatchCommand = ".uno:FormatZErrorBars";
     201           0 :             break;
     202             :         case OBJECTTYPE_DATA_CURVE:
     203           0 :             aDispatchCommand = ".uno:FormatTrendline";
     204           0 :             break;
     205             :         case OBJECTTYPE_DATA_CURVE_EQUATION:
     206           0 :             aDispatchCommand = ".uno:FormatTrendlineEquation";
     207           0 :             break;
     208             :         case OBJECTTYPE_DATA_STOCK_RANGE:
     209           0 :             aDispatchCommand = ".uno:FormatSelection";
     210           0 :             break;
     211             :         case OBJECTTYPE_DATA_STOCK_LOSS:
     212           0 :             aDispatchCommand = ".uno:FormatStockLoss";
     213           0 :             break;
     214             :         case OBJECTTYPE_DATA_STOCK_GAIN:
     215           0 :             aDispatchCommand = ".uno:FormatStockGain";
     216           0 :             break;
     217             :         default: //OBJECTTYPE_UNKNOWN
     218           0 :             break;
     219             :     }
     220           0 :     return aDispatchCommand;
     221             : }
     222             : 
     223             : } // anonymous namespace
     224             : 
     225             : const short HITPIX=2; //hit-tolerance in pixel
     226             : 
     227             : // awt::XWindow
     228          18 : void SAL_CALL ChartController::setPosSize(
     229             :     sal_Int32 X,
     230             :     sal_Int32 Y,
     231             :     sal_Int32 Width,
     232             :     sal_Int32 Height,
     233             :     sal_Int16 Flags )
     234             :         throw (uno::RuntimeException, std::exception)
     235             : {
     236          18 :     SolarMutexGuard aGuard;
     237          36 :     uno::Reference<awt::XWindow> xWindow = m_xViewWindow;
     238             : 
     239          18 :     if(xWindow.is() && m_pChartWindow)
     240             :     {
     241          18 :         Size aLogicSize = m_pChartWindow->PixelToLogic( Size( Width, Height ), MapMode( MAP_100TH_MM )  );
     242             : 
     243             :         //todo: for standalone chart: detect whether we are standalone
     244             :         //change map mode to fit new size
     245          18 :         awt::Size aModelPageSize = ChartModelHelper::getPageSize( getModel() );
     246          18 :         sal_Int32 nScaleXNumerator = aLogicSize.Width();
     247          18 :         sal_Int32 nScaleXDenominator = aModelPageSize.Width;
     248          18 :         sal_Int32 nScaleYNumerator = aLogicSize.Height();
     249          18 :         sal_Int32 nScaleYDenominator = aModelPageSize.Height;
     250             :         MapMode aNewMapMode(
     251             :                     MAP_100TH_MM,
     252             :                     Point(0,0),
     253             :                     Fraction(nScaleXNumerator, nScaleXDenominator),
     254          18 :                     Fraction(nScaleYNumerator, nScaleYDenominator) );
     255          18 :         m_pChartWindow->SetMapMode(aNewMapMode);
     256          18 :         m_pChartWindow->setPosSizePixel( X, Y, Width, Height, Flags );
     257             : 
     258             :         //#i75867# poor quality of ole's alternative view with 3D scenes and zoomfactors besides 100%
     259          36 :         uno::Reference< beans::XPropertySet > xProp( m_xChartView, uno::UNO_QUERY );
     260          18 :         if( xProp.is() )
     261             :         {
     262          18 :             uno::Sequence< beans::PropertyValue > aZoomFactors(4);
     263          18 :             aZoomFactors[0].Name = "ScaleXNumerator";
     264          18 :             aZoomFactors[0].Value = uno::makeAny( nScaleXNumerator );
     265          18 :             aZoomFactors[1].Name = "ScaleXDenominator";
     266          18 :             aZoomFactors[1].Value = uno::makeAny( nScaleXDenominator );
     267          18 :             aZoomFactors[2].Name = "ScaleYNumerator";
     268          18 :             aZoomFactors[2].Value = uno::makeAny( nScaleYNumerator );
     269          18 :             aZoomFactors[3].Name = "ScaleYDenominator";
     270          18 :             aZoomFactors[3].Value = uno::makeAny( nScaleYDenominator );
     271          18 :             xProp->setPropertyValue( "ZoomFactors", uno::makeAny( aZoomFactors ));
     272             :         }
     273             : 
     274             :         //a correct work area is at least necessary for correct values in the position and  size dialog and for dragging area
     275          18 :         if(m_pDrawViewWrapper)
     276             :         {
     277          18 :             Rectangle aRect(Point(0,0), m_pChartWindow->GetOutputSize());
     278          18 :             m_pDrawViewWrapper->SetWorkArea( aRect );
     279             :         }
     280          36 :         m_pChartWindow->Invalidate();
     281          18 :     }
     282          18 : }
     283             : 
     284          33 : awt::Rectangle SAL_CALL ChartController::getPosSize()
     285             :     throw (uno::RuntimeException, std::exception)
     286             : {
     287             :     //@todo
     288          33 :     awt::Rectangle aRet(0, 0, 0, 0);
     289             : 
     290          33 :     uno::Reference<awt::XWindow> xWindow = m_xViewWindow;
     291          33 :     if(xWindow.is())
     292          17 :         aRet = xWindow->getPosSize();
     293             : 
     294          33 :     return aRet;
     295             : }
     296             : 
     297           0 : void SAL_CALL ChartController::setVisible( sal_Bool Visible )
     298             :     throw (uno::RuntimeException, std::exception)
     299             : {
     300             :     //@todo
     301           0 :     uno::Reference<awt::XWindow> xWindow = m_xViewWindow;
     302             : 
     303           0 :     if(xWindow.is())
     304           0 :         xWindow->setVisible( Visible );
     305           0 : }
     306             : 
     307           0 : void SAL_CALL ChartController::setEnable( sal_Bool Enable )
     308             :     throw (uno::RuntimeException, std::exception)
     309             : {
     310             :     //@todo
     311           0 :     uno::Reference<awt::XWindow> xWindow = m_xViewWindow;
     312             : 
     313           0 :     if(xWindow.is())
     314           0 :         xWindow->setEnable( Enable );
     315           0 : }
     316             : 
     317          17 : void SAL_CALL ChartController::setFocus()
     318             :     throw (uno::RuntimeException, std::exception)
     319             : {
     320             :     //@todo
     321          17 :     uno::Reference<awt::XWindow> xWindow = m_xViewWindow;
     322             : 
     323          17 :     if(xWindow.is())
     324          17 :         xWindow->setFocus();
     325          17 : }
     326             : 
     327           0 : void SAL_CALL ChartController::addWindowListener(
     328             :     const uno::Reference< awt::XWindowListener >& xListener )
     329             :         throw (uno::RuntimeException, std::exception)
     330             : {
     331             :     //@todo
     332           0 :     uno::Reference<awt::XWindow> xWindow = m_xViewWindow;
     333             : 
     334           0 :     if(xWindow.is())
     335           0 :         xWindow->addWindowListener( xListener );
     336           0 : }
     337             : 
     338           0 : void SAL_CALL ChartController::removeWindowListener(
     339             :     const uno::Reference< awt::XWindowListener >& xListener )
     340             :         throw (uno::RuntimeException, std::exception)
     341             : {
     342             :     //@todo
     343           0 :     uno::Reference<awt::XWindow> xWindow = m_xViewWindow;
     344             : 
     345           0 :     if(xWindow.is())
     346           0 :         xWindow->removeWindowListener( xListener );
     347           0 : }
     348             : 
     349           0 : void SAL_CALL ChartController::addFocusListener(
     350             :     const uno::Reference< awt::XFocusListener >& xListener )
     351             :         throw (uno::RuntimeException, std::exception)
     352             : {
     353             :     //@todo
     354           0 :     uno::Reference<awt::XWindow> xWindow = m_xViewWindow;
     355             : 
     356           0 :     if(xWindow.is())
     357           0 :         xWindow->addFocusListener( xListener );
     358           0 : }
     359             : 
     360           0 : void SAL_CALL ChartController::removeFocusListener(
     361             :     const uno::Reference< awt::XFocusListener >& xListener )
     362             :         throw (uno::RuntimeException, std::exception)
     363             : {
     364             :     //@todo
     365           0 :     uno::Reference<awt::XWindow> xWindow = m_xViewWindow;
     366             : 
     367           0 :     if(xWindow.is())
     368           0 :         xWindow->removeFocusListener( xListener );
     369           0 : }
     370             : 
     371           0 : void SAL_CALL ChartController::addKeyListener(
     372             :     const uno::Reference< awt::XKeyListener >& xListener )
     373             :         throw (uno::RuntimeException, std::exception)
     374             : {
     375             :     //@todo
     376           0 :     uno::Reference<awt::XWindow> xWindow = m_xViewWindow;
     377             : 
     378           0 :     if(xWindow.is())
     379           0 :         xWindow->addKeyListener( xListener );
     380           0 : }
     381             : 
     382           0 : void SAL_CALL ChartController::removeKeyListener(
     383             :     const uno::Reference< awt::XKeyListener >& xListener )
     384             :         throw (uno::RuntimeException, std::exception)
     385             : {
     386             :     //@todo
     387           0 :     uno::Reference<awt::XWindow> xWindow = m_xViewWindow;
     388             : 
     389           0 :     if(xWindow.is())
     390           0 :         xWindow->removeKeyListener( xListener );
     391           0 : }
     392             : 
     393           0 : void SAL_CALL ChartController::addMouseListener(
     394             :     const uno::Reference< awt::XMouseListener >& xListener )
     395             :         throw (uno::RuntimeException, std::exception)
     396             : {
     397             :     //@todo
     398           0 :     uno::Reference<awt::XWindow> xWindow = m_xViewWindow;
     399             : 
     400           0 :     if(xWindow.is())
     401           0 :         xWindow->addMouseListener( xListener );
     402           0 : }
     403             : 
     404           0 : void SAL_CALL ChartController::removeMouseListener(
     405             :     const uno::Reference< awt::XMouseListener >& xListener )
     406             :         throw (uno::RuntimeException, std::exception)
     407             : {
     408             :     //@todo
     409           0 :     uno::Reference<awt::XWindow> xWindow = m_xViewWindow;
     410             : 
     411           0 :     if(xWindow.is())
     412           0 :         xWindow->removeMouseListener( xListener );
     413           0 : }
     414             : 
     415           0 : void SAL_CALL ChartController::addMouseMotionListener(
     416             :     const uno::Reference< awt::XMouseMotionListener >& xListener )
     417             :         throw (uno::RuntimeException, std::exception)
     418             : {
     419             :     //@todo
     420           0 :     uno::Reference<awt::XWindow> xWindow = m_xViewWindow;
     421             : 
     422           0 :     if(xWindow.is())
     423           0 :         xWindow->addMouseMotionListener( xListener );
     424           0 : }
     425             : 
     426           0 : void SAL_CALL ChartController::removeMouseMotionListener(
     427             :     const uno::Reference< awt::XMouseMotionListener >& xListener )
     428             :         throw (uno::RuntimeException, std::exception)
     429             : {
     430             :     //@todo
     431           0 :     uno::Reference<awt::XWindow> xWindow = m_xViewWindow;
     432             : 
     433           0 :     if(xWindow.is())
     434           0 :         xWindow->removeMouseMotionListener( xListener );
     435           0 : }
     436             : 
     437           0 : void SAL_CALL ChartController::addPaintListener(
     438             :     const uno::Reference< awt::XPaintListener >& xListener )
     439             :         throw (uno::RuntimeException, std::exception)
     440             : {
     441             :     //@todo
     442           0 :     uno::Reference<awt::XWindow> xWindow = m_xViewWindow;
     443             : 
     444           0 :     if(xWindow.is())
     445           0 :         xWindow->addPaintListener( xListener );
     446           0 : }
     447             : 
     448           0 : void SAL_CALL ChartController::removePaintListener(
     449             :     const uno::Reference< awt::XPaintListener >& xListener )
     450             :         throw (uno::RuntimeException, std::exception)
     451             : {
     452             :     //@todo
     453           0 :     uno::Reference<awt::XWindow> xWindow = m_xViewWindow;
     454             : 
     455           0 :     if(xWindow.is())
     456           0 :         xWindow->removePaintListener( xListener );
     457           0 : }
     458             : 
     459             : // impl vcl window controller methods
     460         421 : void ChartController::PrePaint()
     461             : {
     462             :     // forward VCLs PrePaint window event to DrawingLayer
     463         421 :     DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper;
     464             : 
     465         421 :     if(pDrawViewWrapper)
     466             :     {
     467         421 :         pDrawViewWrapper->PrePaint();
     468             :     }
     469         421 : }
     470             : 
     471         397 : void ChartController::execute_Paint( const Rectangle& rRect )
     472             : {
     473             :     try
     474             :     {
     475         397 :         uno::Reference< frame::XModel > xModel( getModel() );
     476             :         //OSL_ENSURE( xModel.is(), "ChartController::execute_Paint: have no model to paint");
     477         397 :         if( !xModel.is() )
     478         401 :             return;
     479             : 
     480             :         //better performance for big data
     481         786 :         uno::Reference< beans::XPropertySet > xProp( m_xChartView, uno::UNO_QUERY );
     482         393 :         if( xProp.is() )
     483             :         {
     484         393 :             awt::Size aResolution(1000, 1000);
     485             :             {
     486         393 :                 SolarMutexGuard aGuard;
     487         393 :                 if( m_pChartWindow )
     488             :                 {
     489         393 :                     aResolution.Width = m_pChartWindow->GetSizePixel().Width();
     490         393 :                     aResolution.Height = m_pChartWindow->GetSizePixel().Height();
     491         393 :                 }
     492             :             }
     493         393 :             xProp->setPropertyValue( "Resolution", uno::makeAny( aResolution ));
     494             :         }
     495             : 
     496             : 
     497         786 :         uno::Reference< util::XUpdatable > xUpdatable( m_xChartView, uno::UNO_QUERY );
     498         393 :         if( xUpdatable.is() )
     499         393 :             xUpdatable->update();
     500             : 
     501             :         {
     502         393 :             SolarMutexGuard aGuard;
     503         393 :             DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper;
     504         393 :             if(pDrawViewWrapper)
     505         393 :                 pDrawViewWrapper->CompleteRedraw(m_pChartWindow, Region(rRect) );
     506         393 :         }
     507             :     }
     508           0 :     catch( const uno::Exception & ex )
     509             :     {
     510             :         ASSERT_EXCEPTION( ex );
     511             :     }
     512           0 :     catch( ... )
     513             :     {
     514             :     }
     515             : }
     516             : 
     517           0 : bool isDoubleClick( const MouseEvent& rMEvt )
     518             : {
     519           0 :     return rMEvt.GetClicks() == 2 && rMEvt.IsLeft() &&
     520           0 :         !rMEvt.IsMod1() && !rMEvt.IsMod2() && !rMEvt.IsShift();
     521             : }
     522             : 
     523           0 : void ChartController::startDoubleClickWaiting()
     524             : {
     525           0 :     SolarMutexGuard aGuard;
     526             : 
     527           0 :     m_bWaitingForDoubleClick = true;
     528             : 
     529           0 :     sal_uLong nDblClkTime = 500;
     530           0 :     if( m_pChartWindow )
     531             :     {
     532           0 :         const MouseSettings& rMSettings = m_pChartWindow->GetSettings().GetMouseSettings();
     533           0 :         nDblClkTime = rMSettings.GetDoubleClickTime();
     534             :     }
     535           0 :     m_aDoubleClickTimer.SetTimeout( nDblClkTime );
     536           0 :     m_aDoubleClickTimer.Start();
     537           0 : }
     538             : 
     539          34 : void ChartController::stopDoubleClickWaiting()
     540             : {
     541          34 :     m_aDoubleClickTimer.Stop();
     542          34 :     m_bWaitingForDoubleClick = false;
     543          34 : }
     544             : 
     545           0 : IMPL_LINK_NOARG(ChartController, DoubleClickWaitingHdl)
     546             : {
     547           0 :     m_bWaitingForDoubleClick = false;
     548             : 
     549           0 :     if( !m_bWaitingForMouseUp && m_aSelection.maybeSwitchSelectionAfterSingleClickWasEnsured() )
     550             :     {
     551           0 :         this->impl_selectObjectAndNotiy();
     552           0 :         SolarMutexGuard aGuard;
     553           0 :         if( m_pChartWindow )
     554             :         {
     555           0 :             Window::PointerState aPointerState( m_pChartWindow->GetPointerState() );
     556             :             MouseEvent aMouseEvent(
     557             :                             aPointerState.maPos,
     558             :                             1/*nClicks*/,
     559             :                             0/*nMode*/,
     560             :                             static_cast< sal_uInt16 >( aPointerState.mnState )/*nButtons*/,
     561           0 :                             0/*nModifier*/ );
     562           0 :             impl_SetMousePointer( aMouseEvent );
     563           0 :         }
     564             :     }
     565             : 
     566           0 :     return 0;
     567             : }
     568             : 
     569           0 : void ChartController::execute_MouseButtonDown( const MouseEvent& rMEvt )
     570             : {
     571           0 :     SolarMutexGuard aGuard;
     572             : 
     573           0 :     m_bWaitingForMouseUp = true;
     574             : 
     575           0 :     if( isDoubleClick(rMEvt) )
     576           0 :         stopDoubleClickWaiting();
     577             :     else
     578           0 :         startDoubleClickWaiting();
     579             : 
     580           0 :     m_aSelection.remindSelectionBeforeMouseDown();
     581             : 
     582           0 :     DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper;
     583           0 :     if(!m_pChartWindow || !pDrawViewWrapper )
     584           0 :         return;
     585             : 
     586           0 :     Point   aMPos   = m_pChartWindow->PixelToLogic(rMEvt.GetPosPixel());
     587             : 
     588           0 :     if ( MOUSE_LEFT == rMEvt.GetButtons() )
     589             :     {
     590           0 :         m_pChartWindow->GrabFocus();
     591           0 :         m_pChartWindow->CaptureMouse();
     592             :     }
     593             : 
     594           0 :     if( pDrawViewWrapper->IsTextEdit() )
     595             :     {
     596           0 :         SdrViewEvent aVEvt;
     597           0 :         if ( pDrawViewWrapper->IsTextEditHit( aMPos, HITPIX ) ||
     598             :              // #i12587# support for shapes in chart
     599           0 :              ( rMEvt.IsRight() && pDrawViewWrapper->PickAnything( rMEvt, SDRMOUSEBUTTONDOWN, aVEvt ) == SDRHIT_MARKEDOBJECT ) )
     600             :         {
     601           0 :             pDrawViewWrapper->MouseButtonDown(rMEvt,m_pChartWindow);
     602           0 :             return;
     603             :         }
     604             :         else
     605             :         {
     606           0 :             this->EndTextEdit();
     607           0 :         }
     608             :     }
     609             : 
     610             :     //abort running action
     611           0 :     if( pDrawViewWrapper->IsAction() )
     612             :     {
     613           0 :         if( rMEvt.IsRight() )
     614           0 :             pDrawViewWrapper->BckAction();
     615           0 :         return;
     616             :     }
     617             : 
     618           0 :     if( isDoubleClick(rMEvt) ) //do not change selection if double click
     619           0 :         return;//double click is handled further in mousebutton up
     620             : 
     621           0 :     SdrHdl* pHitSelectionHdl = 0;
     622             :     //switch from move to resize if handle is hit on a resizable object
     623           0 :     if( m_aSelection.isResizeableObjectSelected() )
     624           0 :         pHitSelectionHdl = pDrawViewWrapper->PickHandle( aMPos );
     625             :     //only change selection if no selection handles are hit
     626           0 :     if( !pHitSelectionHdl )
     627             :     {
     628             :         // #i12587# support for shapes in chart
     629           0 :         if ( m_eDrawMode == CHARTDRAW_INSERT &&
     630           0 :              ( !pDrawViewWrapper->IsMarkedHit( aMPos ) || !m_aSelection.isDragableObjectSelected() ) )
     631             :         {
     632           0 :             if ( m_aSelection.hasSelection() )
     633             :             {
     634           0 :                 m_aSelection.clearSelection();
     635             :             }
     636           0 :             if ( !pDrawViewWrapper->IsAction() )
     637             :             {
     638           0 :                 if ( pDrawViewWrapper->GetCurrentObjIdentifier() == OBJ_CAPTION )
     639             :                 {
     640           0 :                     Size aCaptionSize( 2268, 1134 );
     641           0 :                     pDrawViewWrapper->BegCreateCaptionObj( aMPos, aCaptionSize );
     642             :                 }
     643             :                 else
     644             :                 {
     645           0 :                     pDrawViewWrapper->BegCreateObj( aMPos);
     646             :                 }
     647           0 :                 SdrObject* pObj = pDrawViewWrapper->GetCreateObj();
     648           0 :                 DrawCommandDispatch* pDrawCommandDispatch = m_aDispatchContainer.getDrawCommandDispatch();
     649           0 :                 if ( pObj && m_pDrawModelWrapper && pDrawCommandDispatch )
     650             :                 {
     651           0 :                     SfxItemSet aSet( m_pDrawModelWrapper->GetItemPool() );
     652           0 :                     pDrawCommandDispatch->setAttributes( pObj );
     653           0 :                     pDrawCommandDispatch->setLineEnds( aSet );
     654           0 :                     pObj->SetMergedItemSet( aSet );
     655             :                 }
     656             :             }
     657           0 :             impl_SetMousePointer( rMEvt );
     658           0 :             return;
     659             :         }
     660             : 
     661             :         m_aSelection.adaptSelectionToNewPos(
     662             :                         aMPos,
     663             :                         pDrawViewWrapper,
     664           0 :                         rMEvt.IsRight(),
     665           0 :                         m_bWaitingForDoubleClick );
     666             : 
     667           0 :         if( !m_aSelection.isRotateableObjectSelected( getModel() ) )
     668             :         {
     669           0 :                 m_eDragMode = SDRDRAG_MOVE;
     670           0 :                 pDrawViewWrapper->SetDragMode(m_eDragMode);
     671             :         }
     672             : 
     673           0 :         m_aSelection.applySelection(pDrawViewWrapper);
     674             :     }
     675           0 :     if( m_aSelection.isDragableObjectSelected()
     676           0 :         && !rMEvt.IsRight() )
     677             :     {
     678             :         //start drag
     679           0 :         sal_uInt16  nDrgLog = (sal_uInt16)m_pChartWindow->PixelToLogic(Size(DRGPIX,0)).Width();
     680           0 :         SdrDragMethod* pDragMethod = NULL;
     681             : 
     682             :         //change selection to 3D scene if rotate mode
     683           0 :         SdrDragMode eDragMode = pDrawViewWrapper->GetDragMode();
     684           0 :         if( SDRDRAG_ROTATE==eDragMode )
     685             :         {
     686           0 :             E3dScene* pScene = SelectionHelper::getSceneToRotate( pDrawViewWrapper->getNamedSdrObject( m_aSelection.getSelectedCID() ) );
     687           0 :             if( pScene )
     688             :             {
     689           0 :                 DragMethod_RotateDiagram::RotationDirection eRotationDirection(DragMethod_RotateDiagram::ROTATIONDIRECTION_FREE);
     690           0 :                 if(pHitSelectionHdl)
     691             :                 {
     692           0 :                     SdrHdlKind eKind = pHitSelectionHdl->GetKind();
     693           0 :                     if( eKind==HDL_UPPER || eKind==HDL_LOWER )
     694           0 :                         eRotationDirection = DragMethod_RotateDiagram::ROTATIONDIRECTION_X;
     695           0 :                     else if( eKind==HDL_LEFT || eKind==HDL_RIGHT )
     696           0 :                         eRotationDirection = DragMethod_RotateDiagram::ROTATIONDIRECTION_Y;
     697           0 :                     else if( eKind==HDL_UPLFT || eKind==HDL_UPRGT || eKind==HDL_LWLFT || eKind==HDL_LWRGT )
     698           0 :                         eRotationDirection = DragMethod_RotateDiagram::ROTATIONDIRECTION_Z;
     699             :                 }
     700           0 :                 pDragMethod = new DragMethod_RotateDiagram( *pDrawViewWrapper, m_aSelection.getSelectedCID(), getModel(), eRotationDirection );
     701             :             }
     702             :         }
     703             :         else
     704             :         {
     705           0 :             OUString aDragMethodServiceName( ObjectIdentifier::getDragMethodServiceName( m_aSelection.getSelectedCID() ) );
     706           0 :             if( aDragMethodServiceName.equals( ObjectIdentifier::getPieSegmentDragMethodServiceName() ) )
     707           0 :                 pDragMethod = new DragMethod_PieSegment( *pDrawViewWrapper, m_aSelection.getSelectedCID(), getModel() );
     708             :         }
     709           0 :         pDrawViewWrapper->SdrView::BegDragObj(aMPos, NULL, pHitSelectionHdl, nDrgLog, pDragMethod);
     710             :     }
     711             : 
     712           0 :     impl_SetMousePointer( rMEvt );
     713             : }
     714             : 
     715           0 : void ChartController::execute_MouseMove( const MouseEvent& rMEvt )
     716             : {
     717           0 :     SolarMutexGuard aGuard;
     718             : 
     719           0 :     DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper;
     720           0 :     if(!m_pChartWindow || !pDrawViewWrapper)
     721           0 :         return;
     722             : 
     723           0 :     if( m_pDrawViewWrapper->IsTextEdit() )
     724             :     {
     725           0 :         if( m_pDrawViewWrapper->MouseMove(rMEvt,m_pChartWindow) )
     726           0 :             return;
     727             :     }
     728             : 
     729           0 :     if(pDrawViewWrapper->IsAction())
     730             :     {
     731           0 :         pDrawViewWrapper->MovAction( m_pChartWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
     732             :     }
     733             : 
     734           0 :     impl_SetMousePointer( rMEvt );
     735             : }
     736             : 
     737           0 : void ChartController::execute_Tracking( const TrackingEvent& /* rTEvt */ )
     738             : {
     739           0 : }
     740             : 
     741           0 : void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt )
     742             : {
     743           0 :     ControllerLockGuardUNO aCLGuard( getModel() );
     744           0 :     bool bMouseUpWithoutMouseDown = !m_bWaitingForMouseUp;
     745           0 :     m_bWaitingForMouseUp = false;
     746           0 :     bool bNotifySelectionChange = false;
     747             :     {
     748           0 :         SolarMutexGuard aGuard;
     749             : 
     750           0 :         DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper;
     751           0 :         if(!m_pChartWindow || !pDrawViewWrapper)
     752           0 :             return;
     753             : 
     754           0 :         Point   aMPos   = m_pChartWindow->PixelToLogic(rMEvt.GetPosPixel());
     755             : 
     756           0 :         if(pDrawViewWrapper->IsTextEdit())
     757             :         {
     758           0 :             if( pDrawViewWrapper->MouseButtonUp(rMEvt,m_pChartWindow) )
     759           0 :                 return;
     760             :         }
     761             : 
     762             :         // #i12587# support for shapes in chart
     763           0 :         if ( m_eDrawMode == CHARTDRAW_INSERT && pDrawViewWrapper->IsCreateObj() )
     764             :         {
     765           0 :             pDrawViewWrapper->EndCreateObj( SDRCREATE_FORCEEND );
     766             :             {
     767           0 :                 HiddenUndoContext aUndoContext( m_xUndoManager );
     768             :                     // don't want the positioning Undo action to appear in the UI
     769           0 :                 impl_switchDiagramPositioningToExcludingPositioning();
     770             :             }
     771           0 :             if ( pDrawViewWrapper->AreObjectsMarked() )
     772             :             {
     773           0 :                 if ( pDrawViewWrapper->GetCurrentObjIdentifier() == OBJ_TEXT )
     774             :                 {
     775           0 :                     executeDispatch_EditText();
     776             :                 }
     777             :                 else
     778             :                 {
     779           0 :                     SdrObject* pObj = pDrawViewWrapper->getSelectedObject();
     780           0 :                     if ( pObj )
     781             :                     {
     782           0 :                         uno::Reference< drawing::XShape > xShape( pObj->getUnoShape(), uno::UNO_QUERY );
     783           0 :                         if ( xShape.is() )
     784             :                         {
     785           0 :                             m_aSelection.setSelection( xShape );
     786           0 :                             m_aSelection.applySelection( pDrawViewWrapper );
     787           0 :                         }
     788             :                     }
     789             :                 }
     790             :             }
     791             :             else
     792             :             {
     793           0 :                 m_aSelection.adaptSelectionToNewPos( aMPos, pDrawViewWrapper, rMEvt.IsRight(), m_bWaitingForDoubleClick );
     794           0 :                 m_aSelection.applySelection( pDrawViewWrapper );
     795           0 :                 setDrawMode( CHARTDRAW_SELECT );
     796             :             }
     797             :         }
     798           0 :         else if ( pDrawViewWrapper->IsDragObj() )
     799             :         {
     800           0 :             bool bDraggingDone = false;
     801           0 :             SdrDragMethod* pDragMethod = pDrawViewWrapper->SdrView::GetDragMethod();
     802           0 :             bool bIsMoveOnly = pDragMethod ? pDragMethod->getMoveOnly() : false;
     803           0 :             DragMethod_Base* pChartDragMethod = dynamic_cast< DragMethod_Base* >(pDragMethod);
     804           0 :             if( pChartDragMethod )
     805             :             {
     806           0 :                 UndoGuard aUndoGuard( pChartDragMethod->getUndoDescription(),
     807           0 :                         m_xUndoManager );
     808             : 
     809           0 :                 if( pDrawViewWrapper->EndDragObj(false) )
     810             :                 {
     811           0 :                     bDraggingDone = true;
     812           0 :                     aUndoGuard.commit();
     813           0 :                 }
     814             :             }
     815             : 
     816           0 :             if( !bDraggingDone && pDrawViewWrapper->EndDragObj(false) )
     817             :             {
     818             :                 try
     819             :                 {
     820             :                     //end move or size
     821           0 :                     SdrObject* pObj = pDrawViewWrapper->getSelectedObject();
     822           0 :                     if( pObj )
     823             :                     {
     824           0 :                         Rectangle aObjectRect = pObj->GetSnapRect();
     825           0 :                         awt::Size aPageSize( ChartModelHelper::getPageSize( getModel() ) );
     826           0 :                         Rectangle aPageRect( 0,0,aPageSize.Width,aPageSize.Height );
     827             : 
     828           0 :                         const E3dObject* pE3dObject = dynamic_cast< const E3dObject*>( pObj );
     829           0 :                         if( pE3dObject )
     830           0 :                             aObjectRect = pE3dObject->GetScene()->GetSnapRect();
     831             : 
     832           0 :                         ActionDescriptionProvider::ActionType eActionType(ActionDescriptionProvider::MOVE);
     833           0 :                         if( !bIsMoveOnly && m_aSelection.isResizeableObjectSelected() )
     834           0 :                             eActionType = ActionDescriptionProvider::RESIZE;
     835             : 
     836           0 :                         ObjectType eObjectType = ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() );
     837             : 
     838             :                         UndoGuard aUndoGuard(
     839             :                             ActionDescriptionProvider::createDescription( eActionType, ObjectNameProvider::getName( eObjectType)),
     840           0 :                             m_xUndoManager );
     841             : 
     842           0 :                         bool bChanged = false;
     843           0 :                         ChartModel* pModel = dynamic_cast<ChartModel*>(getModel().get());
     844           0 :                         if ( eObjectType == OBJECTTYPE_LEGEND )
     845           0 :                             bChanged = DiagramHelper::switchDiagramPositioningToExcludingPositioning( *pModel, false , true );
     846             : 
     847             :                         bool bMoved = PositionAndSizeHelper::moveObject( m_aSelection.getSelectedCID()
     848           0 :                                         , getModel()
     849           0 :                                         , awt::Rectangle(aObjectRect.getX(),aObjectRect.getY(),aObjectRect.getWidth(),aObjectRect.getHeight())
     850           0 :                                         , awt::Rectangle(aPageRect.getX(),aPageRect.getY(),aPageRect.getWidth(),aPageRect.getHeight()) );
     851             : 
     852           0 :                         if( bMoved || bChanged )
     853             :                         {
     854           0 :                             bDraggingDone = true;
     855           0 :                             aUndoGuard.commit();
     856           0 :                         }
     857             :                     }
     858             :                 }
     859           0 :                 catch( const uno::Exception & ex )
     860             :                 {
     861             :                     ASSERT_EXCEPTION( ex );
     862             :                 }
     863             :                 //all wanted model changes will take effect
     864             :                 //and all unwanted view modifications are cleaned
     865             :             }
     866             : 
     867           0 :             if( !bDraggingDone ) //mouse wasn't moved while dragging
     868             :             {
     869           0 :                 bool bClickedTwiceOnDragableObject = SelectionHelper::isDragableObjectHitTwice( aMPos, m_aSelection.getSelectedCID(), *pDrawViewWrapper );
     870           0 :                 bool bIsRotateable = m_aSelection.isRotateableObjectSelected( getModel() );
     871             : 
     872             :                 //toggel between move and rotate
     873           0 :                 if( bIsRotateable && bClickedTwiceOnDragableObject && SDRDRAG_MOVE==m_eDragMode )
     874           0 :                     m_eDragMode=SDRDRAG_ROTATE;
     875             :                 else
     876           0 :                     m_eDragMode=SDRDRAG_MOVE;
     877             : 
     878           0 :                 pDrawViewWrapper->SetDragMode(m_eDragMode);
     879             : 
     880           0 :                 if( !m_bWaitingForDoubleClick && m_aSelection.maybeSwitchSelectionAfterSingleClickWasEnsured() )
     881             :                 {
     882           0 :                     this->impl_selectObjectAndNotiy();
     883             :                 }
     884             :             }
     885             :             else
     886           0 :                 m_aSelection.resetPossibleSelectionAfterSingleClickWasEnsured();
     887             :         }
     888           0 :         else if( isDoubleClick(rMEvt) && !bMouseUpWithoutMouseDown /*#i106966#*/ )
     889             :         {
     890           0 :             Point aMousePixel = rMEvt.GetPosPixel();
     891           0 :             execute_DoubleClick( &aMousePixel );
     892             :         }
     893             : 
     894             :         //@todo ForcePointer(&rMEvt);
     895           0 :         m_pChartWindow->ReleaseMouse();
     896             : 
     897           0 :         if( m_aSelection.isSelectionDifferentFromBeforeMouseDown() )
     898           0 :             bNotifySelectionChange = true;
     899             :     }
     900             : 
     901           0 :     impl_SetMousePointer( rMEvt );
     902             : 
     903           0 :     if(bNotifySelectionChange)
     904           0 :         impl_notifySelectionChangeListeners();
     905             : }
     906             : 
     907           0 : void ChartController::execute_DoubleClick( const Point* pMousePixel )
     908             : {
     909           0 :     bool bEditText = false;
     910           0 :     if ( m_aSelection.hasSelection() )
     911             :     {
     912           0 :         OUString aCID( m_aSelection.getSelectedCID() );
     913           0 :         if ( !aCID.isEmpty() )
     914             :         {
     915           0 :             ObjectType eObjectType = ObjectIdentifier::getObjectType( aCID );
     916           0 :             if ( OBJECTTYPE_TITLE == eObjectType )
     917             :             {
     918           0 :                 bEditText = true;
     919             :             }
     920             :         }
     921             :         else
     922             :         {
     923             :             // #i12587# support for shapes in chart
     924           0 :             SdrObject* pObj = DrawViewWrapper::getSdrObject( m_aSelection.getSelectedAdditionalShape() );
     925           0 :             if ( pObj && pObj->ISA( SdrTextObj ) )
     926             :             {
     927           0 :                 bEditText = true;
     928             :             }
     929           0 :         }
     930             :     }
     931             : 
     932           0 :     if ( bEditText )
     933             :     {
     934           0 :         executeDispatch_EditText( pMousePixel );
     935             :     }
     936             :     else
     937             :     {
     938           0 :         executeDispatch_ObjectProperties();
     939             :     }
     940           0 : }
     941             : 
     942          34 : void ChartController::execute_Resize()
     943             : {
     944          34 :     SolarMutexGuard aGuard;
     945          34 :     if(m_pChartWindow)
     946          34 :         m_pChartWindow->Invalidate();
     947          34 : }
     948             : 
     949           0 : void ChartController::execute_Activate()
     950             : {
     951             :     ///// pDrawViewWrapper->SetEditMode(sal_True);
     952           0 : }
     953             : 
     954           0 : void ChartController::execute_Deactivate()
     955             : {
     956             :     /*
     957             :     pDrawViewWrapper->SetEditMode(sal_False);
     958             :     this->ReleaseMouse();
     959             :     */
     960           0 : }
     961             : 
     962          17 : void ChartController::execute_GetFocus()
     963             : {
     964          17 : }
     965             : 
     966           2 : void ChartController::execute_LoseFocus()
     967             : {
     968             :     //this->ReleaseMouse();
     969           2 : }
     970             : 
     971           0 : void ChartController::execute_Command( const CommandEvent& rCEvt )
     972             : {
     973           0 :     bool bIsAction = false;
     974             :     {
     975           0 :         SolarMutexGuard aGuard;
     976           0 :         DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper;
     977           0 :         if(!m_pChartWindow || !pDrawViewWrapper)
     978           0 :             return;
     979           0 :         bIsAction = m_pDrawViewWrapper->IsAction();
     980             :     }
     981             : 
     982             :     // pop-up menu
     983           0 :     if(rCEvt.GetCommand() == COMMAND_CONTEXTMENU && !bIsAction)
     984             :     {
     985             :         {
     986           0 :             SolarMutexGuard aGuard;
     987           0 :             if(m_pChartWindow)
     988           0 :                 m_pChartWindow->ReleaseMouse();
     989             :         }
     990             : 
     991           0 :         if( m_aSelection.isSelectionDifferentFromBeforeMouseDown() )
     992           0 :             impl_notifySelectionChangeListeners();
     993             : 
     994           0 :         if ( isShapeContext() )
     995             :         {
     996             :             // #i12587# support for shapes in chart
     997           0 :             PopupMenu aContextMenu( SchResId( m_pDrawViewWrapper->IsTextEdit() ?
     998           0 :                 RID_CONTEXTMENU_SHAPEEDIT : RID_CONTEXTMENU_SHAPE ) );
     999           0 :             ::svt::ContextMenuHelper aContextMenuHelper( m_xFrame );
    1000           0 :             Point aPos( rCEvt.GetMousePosPixel() );
    1001           0 :             if( !rCEvt.IsMouseEvent() )
    1002             :             {
    1003           0 :                 SolarMutexGuard aGuard;
    1004           0 :                 if(m_pChartWindow)
    1005           0 :                     aPos = m_pChartWindow->GetPointerState().maPos;
    1006             :             }
    1007           0 :             aContextMenuHelper.completeAndExecute( aPos, aContextMenu );
    1008             :         }
    1009             :         else
    1010             :         {
    1011             :             // todo: the context menu should be specified by an xml file in uiconfig
    1012             :             uno::Reference< awt::XPopupMenu > xPopupMenu(
    1013           0 :                 m_xCC->getServiceManager()->createInstanceWithContext(
    1014           0 :                     "com.sun.star.awt.PopupMenu", m_xCC ), uno::UNO_QUERY );
    1015           0 :             if( xPopupMenu.is())
    1016             :             {
    1017           0 :                 sal_Int16 nUniqueId = 1;
    1018           0 :                 ObjectType eObjectType = ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() );
    1019           0 :                 Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( getModel() );
    1020             : 
    1021           0 :                 OUString aFormatCommand( lcl_getFormatCommandForObjectCID( m_aSelection.getSelectedCID() ) );
    1022           0 :                 lcl_insertMenuCommand( xPopupMenu, nUniqueId++, aFormatCommand );
    1023             : 
    1024             :                 //some commands for dataseries and points:
    1025             : 
    1026           0 :                 if( OBJECTTYPE_DATA_SERIES == eObjectType || OBJECTTYPE_DATA_POINT == eObjectType )
    1027             :                 {
    1028           0 :                     bool bIsPoint = ( OBJECTTYPE_DATA_POINT == eObjectType );
    1029           0 :                     uno::Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() );
    1030           0 :                     uno::Reference< chart2::XRegressionCurveContainer > xCurveCnt( xSeries, uno::UNO_QUERY );
    1031           0 :                     Reference< chart2::XRegressionCurve > xTrendline( RegressionCurveHelper::getFirstCurveNotMeanValueLine( xCurveCnt ) );
    1032           0 :                     bool bHasEquation = RegressionCurveHelper::hasEquation( xTrendline );
    1033           0 :                     Reference< chart2::XRegressionCurve > xMeanValue( RegressionCurveHelper::getMeanValueLine( xCurveCnt ) );
    1034           0 :                     bool bHasYErrorBars = StatisticsHelper::hasErrorBars( xSeries, true );
    1035           0 :                     bool bHasXErrorBars = StatisticsHelper::hasErrorBars( xSeries, false );
    1036           0 :                     bool bHasDataLabelsAtSeries = DataSeriesHelper::hasDataLabelsAtSeries( xSeries );
    1037           0 :                     bool bHasDataLabelsAtPoints = DataSeriesHelper::hasDataLabelsAtPoints( xSeries );
    1038           0 :                     bool bHasDataLabelAtPoint = false;
    1039           0 :                     sal_Int32 nPointIndex = -1;
    1040           0 :                     if( bIsPoint )
    1041             :                     {
    1042           0 :                         nPointIndex = ObjectIdentifier::getIndexFromParticleOrCID( m_aSelection.getSelectedCID() );
    1043           0 :                         bHasDataLabelAtPoint = DataSeriesHelper::hasDataLabelAtPoint( xSeries, nPointIndex );
    1044             :                     }
    1045           0 :                     bool bSelectedPointIsFormatted = false;
    1046           0 :                     bool bHasFormattedDataPointsOtherThanSelected = false;
    1047             : 
    1048           0 :                     Reference< beans::XPropertySet > xSeriesProperties( xSeries, uno::UNO_QUERY );
    1049           0 :                     if( xSeriesProperties.is() )
    1050             :                     {
    1051           0 :                         uno::Sequence< sal_Int32 > aAttributedDataPointIndexList;
    1052           0 :                         if( xSeriesProperties->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList )
    1053             :                         {
    1054           0 :                             if( aAttributedDataPointIndexList.hasElements() )
    1055             :                             {
    1056           0 :                                 if( bIsPoint )
    1057             :                                 {
    1058           0 :                                     ::std::vector< sal_Int32 > aIndices( ContainerHelper::SequenceToVector( aAttributedDataPointIndexList ) );
    1059           0 :                                     ::std::vector< sal_Int32 >::iterator aIt = ::std::find( aIndices.begin(), aIndices.end(), nPointIndex );
    1060           0 :                                     if( aIt != aIndices.end())
    1061           0 :                                         bSelectedPointIsFormatted = true;
    1062             :                                     else
    1063           0 :                                         bHasFormattedDataPointsOtherThanSelected = true;
    1064             :                                 }
    1065             :                                 else
    1066           0 :                                     bHasFormattedDataPointsOtherThanSelected = true;
    1067             :                             }
    1068           0 :                         }
    1069             :                     }
    1070             : 
    1071           0 :                     if( bIsPoint )
    1072             :                     {
    1073           0 :                         if( bHasDataLabelAtPoint )
    1074           0 :                             lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatDataLabel" );
    1075           0 :                         if( !bHasDataLabelAtPoint )
    1076           0 :                             lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertDataLabel" );
    1077             :                         else
    1078           0 :                             lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteDataLabel" );
    1079           0 :                         if( bSelectedPointIsFormatted )
    1080           0 :                             lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:ResetDataPoint" );
    1081             : 
    1082           0 :                         xPopupMenu->insertSeparator( -1 );
    1083             : 
    1084           0 :                         lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatDataSeries" );
    1085             :                     }
    1086             : 
    1087           0 :                     Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) );
    1088           0 :                     if( xChartType->getChartType().equals(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
    1089             :                     {
    1090             :                         try
    1091             :                         {
    1092           0 :                             Reference< beans::XPropertySet > xChartTypeProp( xChartType, uno::UNO_QUERY );
    1093           0 :                             if( xChartTypeProp.is() )
    1094             :                             {
    1095           0 :                                 bool bJapaneseStyle = false;
    1096           0 :                                 xChartTypeProp->getPropertyValue( "Japanese" ) >>= bJapaneseStyle;
    1097             : 
    1098           0 :                                 if( bJapaneseStyle )
    1099             :                                 {
    1100           0 :                                     lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatStockLoss" );
    1101           0 :                                     lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatStockGain" );
    1102             :                                 }
    1103           0 :                             }
    1104             :                         }
    1105           0 :                         catch( const uno::Exception & ex )
    1106             :                         {
    1107             :                             ASSERT_EXCEPTION( ex );
    1108             :                         }
    1109             :                     }
    1110             : 
    1111           0 :                     if( bHasDataLabelsAtSeries )
    1112           0 :                         lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatDataLabels" );
    1113           0 :                     if( bHasEquation )
    1114           0 :                         lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatTrendlineEquation" );
    1115           0 :                     if( xMeanValue.is() )
    1116           0 :                         lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatMeanValue" );
    1117           0 :                     if( bHasXErrorBars )
    1118           0 :                         lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatXErrorBars" );
    1119           0 :                     if( bHasYErrorBars )
    1120           0 :                         lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatYErrorBars" );
    1121             : 
    1122           0 :                     xPopupMenu->insertSeparator( -1 );
    1123             : 
    1124           0 :                     if( !bHasDataLabelsAtSeries )
    1125           0 :                         lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertDataLabels" );
    1126             : 
    1127           0 :                     lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertTrendline" );
    1128             : 
    1129           0 :                     if( !xMeanValue.is() )
    1130           0 :                         lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertMeanValue" );
    1131           0 :                     if( !bHasXErrorBars )
    1132           0 :                         lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertXErrorBars" );
    1133           0 :                     if( !bHasYErrorBars )
    1134           0 :                         lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertYErrorBars" );
    1135           0 :                     if( bHasDataLabelsAtSeries || ( bHasDataLabelsAtPoints && bHasFormattedDataPointsOtherThanSelected ) )
    1136           0 :                         lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteDataLabels" );
    1137           0 :                     if( bHasEquation )
    1138           0 :                         lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteTrendlineEquation" );
    1139           0 :                     if( xMeanValue.is() )
    1140           0 :                         lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteMeanValue" );
    1141           0 :                     if( bHasXErrorBars )
    1142           0 :                         lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteXErrorBars" );
    1143           0 :                     if( bHasYErrorBars )
    1144           0 :                         lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteYErrorBars" );
    1145             : 
    1146           0 :                     if( bHasFormattedDataPointsOtherThanSelected )
    1147           0 :                         lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:ResetAllDataPoints" );
    1148             : 
    1149           0 :                     xPopupMenu->insertSeparator( -1 );
    1150             : 
    1151           0 :                     lcl_insertMenuCommand( xPopupMenu, nUniqueId, ".uno:ArrangeRow" );
    1152             :                     uno::Reference< awt::XPopupMenu > xArrangePopupMenu(
    1153           0 :                         m_xCC->getServiceManager()->createInstanceWithContext(
    1154           0 :                             "com.sun.star.awt.PopupMenu", m_xCC ), uno::UNO_QUERY );
    1155           0 :                     if( xArrangePopupMenu.is() )
    1156             :                     {
    1157           0 :                         sal_Int16 nSubId = nUniqueId + 1;
    1158           0 :                         lcl_insertMenuCommand( xArrangePopupMenu, nSubId++, ".uno:Forward" );
    1159           0 :                         lcl_insertMenuCommand( xArrangePopupMenu, nSubId, ".uno:Backward" );
    1160           0 :                         xPopupMenu->setPopupMenu( nUniqueId, xArrangePopupMenu );
    1161           0 :                         nUniqueId = nSubId;
    1162             :                     }
    1163           0 :                     ++nUniqueId;
    1164             :                 }
    1165           0 :                 else if( OBJECTTYPE_DATA_CURVE == eObjectType )
    1166             :                 {
    1167           0 :                     lcl_insertMenuCommand( xPopupMenu,  nUniqueId++, ".uno:DeleteTrendline" );
    1168           0 :                     lcl_insertMenuCommand( xPopupMenu,  nUniqueId++, ".uno:FormatTrendlineEquation" );
    1169           0 :                     lcl_insertMenuCommand( xPopupMenu,  nUniqueId++, ".uno:InsertTrendlineEquation" );
    1170           0 :                     lcl_insertMenuCommand( xPopupMenu,  nUniqueId++, ".uno:InsertTrendlineEquationAndR2" );
    1171           0 :                     lcl_insertMenuCommand( xPopupMenu,  nUniqueId++, ".uno:InsertR2Value" );
    1172           0 :                     lcl_insertMenuCommand( xPopupMenu,  nUniqueId++, ".uno:DeleteTrendlineEquation" );
    1173           0 :                     lcl_insertMenuCommand( xPopupMenu,  nUniqueId++, ".uno:DeleteR2Value" );
    1174             :                 }
    1175           0 :                 else if( OBJECTTYPE_DATA_CURVE_EQUATION == eObjectType )
    1176             :                 {
    1177           0 :                     lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertR2Value" );
    1178           0 :                     lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteR2Value" );
    1179             :                 }
    1180             : 
    1181             :                 //some commands for axes: and grids
    1182             : 
    1183           0 :                 else if( OBJECTTYPE_AXIS  == eObjectType || OBJECTTYPE_GRID == eObjectType || OBJECTTYPE_SUBGRID == eObjectType )
    1184             :                 {
    1185           0 :                     Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getModel() );
    1186           0 :                     if( xAxis.is() && xDiagram.is() )
    1187             :                     {
    1188           0 :                         sal_Int32 nDimensionIndex = -1;
    1189           0 :                         sal_Int32 nCooSysIndex = -1;
    1190           0 :                         sal_Int32 nAxisIndex = -1;
    1191           0 :                         AxisHelper::getIndicesForAxis( xAxis, xDiagram, nCooSysIndex, nDimensionIndex, nAxisIndex );
    1192           0 :                         bool bIsSecondaryAxis = nAxisIndex!=0;
    1193           0 :                         bool bIsAxisVisible = AxisHelper::isAxisVisible( xAxis );
    1194           0 :                         bool bIsMajorGridVisible = AxisHelper::isGridShown( nDimensionIndex, nCooSysIndex, true /*bMainGrid*/, xDiagram );
    1195           0 :                         bool bIsMinorGridVisible = AxisHelper::isGridShown( nDimensionIndex, nCooSysIndex, false /*bMainGrid*/, xDiagram );
    1196           0 :                         bool bHasTitle = false;
    1197           0 :                         uno::Reference< XTitled > xTitled( xAxis, uno::UNO_QUERY );
    1198           0 :                         if( xTitled.is())
    1199           0 :                             bHasTitle = !TitleHelper::getCompleteString( xTitled->getTitleObject() ).isEmpty();
    1200             : 
    1201           0 :                         if( OBJECTTYPE_AXIS  != eObjectType && bIsAxisVisible )
    1202           0 :                             lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatAxis" );
    1203           0 :                         if( OBJECTTYPE_GRID != eObjectType && bIsMajorGridVisible && !bIsSecondaryAxis )
    1204           0 :                             lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatMajorGrid" );
    1205           0 :                         if( OBJECTTYPE_SUBGRID != eObjectType && bIsMinorGridVisible && !bIsSecondaryAxis )
    1206           0 :                             lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatMinorGrid" );
    1207             : 
    1208           0 :                         xPopupMenu->insertSeparator( -1 );
    1209             : 
    1210           0 :                         if( OBJECTTYPE_AXIS  != eObjectType && !bIsAxisVisible )
    1211           0 :                             lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertAxis" );
    1212           0 :                         if( OBJECTTYPE_GRID != eObjectType && !bIsMajorGridVisible && !bIsSecondaryAxis )
    1213           0 :                             lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertMajorGrid" );
    1214           0 :                         if( OBJECTTYPE_SUBGRID != eObjectType && !bIsMinorGridVisible && !bIsSecondaryAxis )
    1215           0 :                             lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertMinorGrid" );
    1216           0 :                         if( !bHasTitle )
    1217           0 :                             lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertAxisTitle" );
    1218             : 
    1219           0 :                         if( bIsAxisVisible )
    1220           0 :                             lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteAxis" );
    1221           0 :                         if( bIsMajorGridVisible && !bIsSecondaryAxis )
    1222           0 :                             lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteMajorGrid" );
    1223           0 :                         if( bIsMinorGridVisible && !bIsSecondaryAxis )
    1224           0 :                             lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteMinorGrid" );
    1225           0 :                     }
    1226             :                 }
    1227             : 
    1228           0 :                 if( OBJECTTYPE_DATA_STOCK_LOSS == eObjectType )
    1229           0 :                     lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatStockGain" );
    1230           0 :                 else if( OBJECTTYPE_DATA_STOCK_GAIN == eObjectType )
    1231           0 :                     lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatStockLoss" );
    1232             : 
    1233           0 :                 lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:TransformDialog" );
    1234             : 
    1235           0 :                 if( OBJECTTYPE_PAGE == eObjectType || OBJECTTYPE_DIAGRAM == eObjectType
    1236           0 :                     || OBJECTTYPE_DIAGRAM_WALL == eObjectType
    1237           0 :                     || OBJECTTYPE_DIAGRAM_FLOOR == eObjectType
    1238           0 :                     || OBJECTTYPE_UNKNOWN == eObjectType )
    1239             :                 {
    1240           0 :                     if( OBJECTTYPE_UNKNOWN != eObjectType )
    1241           0 :                         xPopupMenu->insertSeparator( -1 );
    1242           0 :                     bool bHasLegend = LegendHelper::hasLegend( xDiagram );
    1243           0 :                     lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertTitles" );
    1244           0 :                     if( !bHasLegend )
    1245           0 :                         lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertLegend" );
    1246           0 :                     lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertRemoveAxes" );
    1247           0 :                     if( bHasLegend )
    1248           0 :                         lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteLegend" );
    1249             :                 }
    1250             : 
    1251             : 
    1252           0 :                 xPopupMenu->insertSeparator( -1 );
    1253           0 :                 lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DiagramType" );
    1254           0 :                 lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DataRanges" );
    1255           0 :                 lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DiagramData" );
    1256           0 :                 lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:View3D" );
    1257           0 :                 xPopupMenu->insertSeparator( -1 );
    1258           0 :                 lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:Cut" );
    1259           0 :                 lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:Copy" );
    1260           0 :                 lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:Paste" );
    1261             : 
    1262           0 :                 ::svt::ContextMenuHelper aContextMenuHelper( m_xFrame );
    1263           0 :                 Point aPos( rCEvt.GetMousePosPixel() );
    1264           0 :                 if( !rCEvt.IsMouseEvent() )
    1265             :                 {
    1266           0 :                     SolarMutexGuard aGuard;
    1267           0 :                     if(m_pChartWindow)
    1268           0 :                         aPos = m_pChartWindow->GetPointerState().maPos;
    1269             :                 }
    1270           0 :                 aContextMenuHelper.completeAndExecute( aPos, xPopupMenu );
    1271           0 :             }
    1272             :         }
    1273             :     }
    1274           0 :     else if( ( rCEvt.GetCommand() == COMMAND_STARTEXTTEXTINPUT ) ||
    1275           0 :              ( rCEvt.GetCommand() == COMMAND_EXTTEXTINPUT ) ||
    1276           0 :              ( rCEvt.GetCommand() == COMMAND_ENDEXTTEXTINPUT ) ||
    1277           0 :              ( rCEvt.GetCommand() == COMMAND_INPUTCONTEXTCHANGE ) )
    1278             :     {
    1279             :         //#i84417# enable editing with IME
    1280           0 :         SolarMutexGuard aGuard;
    1281           0 :         if( m_pDrawViewWrapper )
    1282           0 :             m_pDrawViewWrapper->Command( rCEvt, m_pChartWindow );
    1283             :     }
    1284             : }
    1285             : 
    1286           0 : bool ChartController::execute_KeyInput( const KeyEvent& rKEvt )
    1287             : {
    1288           0 :     bool bReturn=false;
    1289             : 
    1290           0 :     DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper;
    1291           0 :     if(!m_pChartWindow || !pDrawViewWrapper)
    1292           0 :         return bReturn;
    1293             : 
    1294             :     // handle accelerators
    1295           0 :     if( ! m_apAccelExecute.get() && m_xFrame.is() && m_xCC.is() )
    1296             :     {
    1297           0 :         m_apAccelExecute.reset( ::svt::AcceleratorExecute::createAcceleratorHelper());
    1298             :         OSL_ASSERT( m_apAccelExecute.get());
    1299           0 :         if( m_apAccelExecute.get() )
    1300           0 :             m_apAccelExecute->init( m_xCC, m_xFrame );
    1301             :     }
    1302             : 
    1303           0 :     KeyCode aKeyCode( rKEvt.GetKeyCode());
    1304           0 :     sal_uInt16 nCode = aKeyCode.GetCode();
    1305           0 :     bool bAlternate = aKeyCode.IsMod2();
    1306           0 :     bool bCtrl = aKeyCode.IsMod1();
    1307             : 
    1308           0 :     if( m_apAccelExecute.get() )
    1309           0 :         bReturn = m_apAccelExecute->execute( aKeyCode );
    1310           0 :     if( bReturn )
    1311           0 :         return bReturn;
    1312             : 
    1313             :     {
    1314           0 :         SolarMutexGuard aGuard;
    1315           0 :         if( pDrawViewWrapper->IsTextEdit() )
    1316             :         {
    1317           0 :             if( pDrawViewWrapper->KeyInput(rKEvt,m_pChartWindow) )
    1318             :             {
    1319           0 :                 bReturn = true;
    1320           0 :                 if( nCode == KEY_ESCAPE )
    1321             :                 {
    1322           0 :                     this->EndTextEdit();
    1323             :                 }
    1324             :             }
    1325           0 :         }
    1326             :     }
    1327             : 
    1328             :     // keyboard accessibility
    1329           0 :     ObjectType eObjectType = ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() );
    1330           0 :     if( ! bReturn )
    1331             :     {
    1332             :         // Natvigation (Tab/F3/Home/End)
    1333           0 :         uno::Reference< XChartDocument > xChartDoc( getModel(), uno::UNO_QUERY );
    1334           0 :         ObjectKeyNavigation aObjNav( m_aSelection.getSelectedOID(), xChartDoc, ExplicitValueProvider::getExplicitValueProvider( m_xChartView ));
    1335           0 :         awt::KeyEvent aKeyEvent( ::svt::AcceleratorExecute::st_VCLKey2AWTKey( aKeyCode ));
    1336           0 :         bReturn = aObjNav.handleKeyEvent( aKeyEvent );
    1337           0 :         if( bReturn )
    1338             :         {
    1339           0 :             ObjectIdentifier aNewOID = aObjNav.getCurrentSelection();
    1340           0 :             uno::Any aNewSelection;
    1341           0 :             if ( aNewOID.isValid() && !ObjectHierarchy::isRootNode( aNewOID ) )
    1342             :             {
    1343           0 :                 aNewSelection = aNewOID.getAny();
    1344             :             }
    1345           0 :             if ( m_eDragMode == SDRDRAG_ROTATE && !SelectionHelper::isRotateableObject( aNewOID.getObjectCID(), getModel() ) )
    1346             :             {
    1347           0 :                 m_eDragMode = SDRDRAG_MOVE;
    1348             :             }
    1349           0 :             bReturn = select( aNewSelection );
    1350           0 :         }
    1351             :     }
    1352             : 
    1353             :     // Position and Size (+/-/arrow-keys) or pie segment dragging
    1354           0 :     if( ! bReturn  )
    1355             :     {
    1356             :         // pie segment dragging
    1357             :         // note: could also be done for data series
    1358           0 :         if( eObjectType == OBJECTTYPE_DATA_POINT &&
    1359             :             ObjectIdentifier::getDragMethodServiceName( m_aSelection.getSelectedCID() ).equals(
    1360           0 :                 ObjectIdentifier::getPieSegmentDragMethodServiceName()))
    1361             :         {
    1362           0 :             bool bDrag = false;
    1363           0 :             bool bDragInside = false;
    1364           0 :             if( nCode == KEY_ADD ||
    1365             :                 nCode == KEY_SUBTRACT )
    1366             :             {
    1367           0 :                 bDrag = true;
    1368           0 :                 bDragInside = ( nCode == KEY_SUBTRACT );
    1369             :             }
    1370           0 :             else if(
    1371           0 :                 nCode == KEY_LEFT ||
    1372           0 :                 nCode == KEY_RIGHT ||
    1373           0 :                 nCode == KEY_UP ||
    1374             :                 nCode == KEY_DOWN )
    1375             :             {
    1376           0 :                 bDrag = true;
    1377           0 :                 OUString aParameter( ObjectIdentifier::getDragParameterString( m_aSelection.getSelectedCID() ));
    1378           0 :                 sal_Int32 nOffsetPercentDummy( 0 );
    1379           0 :                 awt::Point aMinimumPosition( 0, 0 );
    1380           0 :                 awt::Point aMaximumPosition( 0, 0 );
    1381             :                 ObjectIdentifier::parsePieSegmentDragParameterString(
    1382           0 :                     aParameter, nOffsetPercentDummy, aMinimumPosition, aMaximumPosition );
    1383           0 :                 aMaximumPosition.Y -= aMinimumPosition.Y;
    1384           0 :                 aMaximumPosition.X -= aMinimumPosition.X;
    1385             : 
    1386             :                 bDragInside =
    1387           0 :                     (nCode == KEY_RIGHT && (aMaximumPosition.X < 0)) ||
    1388           0 :                     (nCode == KEY_LEFT  && (aMaximumPosition.X > 0)) ||
    1389           0 :                     (nCode == KEY_DOWN  && (aMaximumPosition.Y < 0)) ||
    1390           0 :                     (nCode == KEY_UP    && (aMaximumPosition.Y > 0));
    1391             :             }
    1392             : 
    1393           0 :             if( bDrag )
    1394             :             {
    1395           0 :                 double fAmount = bAlternate ? 0.01 : 0.05;
    1396           0 :                 if( bDragInside )
    1397           0 :                     fAmount *= -1.0;
    1398             : 
    1399           0 :                 bReturn = impl_DragDataPoint( m_aSelection.getSelectedCID(), fAmount );
    1400             :             }
    1401             :         }
    1402             :         else
    1403             :         {
    1404             :             // size
    1405           0 :             if( nCode == KEY_ADD ||
    1406             :                 nCode == KEY_SUBTRACT )
    1407             :             {
    1408           0 :                 if( eObjectType == OBJECTTYPE_DIAGRAM )
    1409             :                 {
    1410             :                     // default 1 mm in each direction
    1411           0 :                     double fGrowAmountX = 200.0;
    1412           0 :                     double fGrowAmountY = 200.0;
    1413           0 :                     if( bAlternate && m_pChartWindow )
    1414             :                     {
    1415             :                         // together with Alt-key: 1 px in each direction
    1416           0 :                         SolarMutexGuard aGuard;
    1417           0 :                         if( m_pChartWindow )
    1418             :                         {
    1419           0 :                             Size aPixelSize = m_pChartWindow->PixelToLogic( Size( 2, 2 ));
    1420           0 :                             fGrowAmountX = static_cast< double >( aPixelSize.Width());
    1421           0 :                             fGrowAmountY = static_cast< double >( aPixelSize.Height());
    1422           0 :                         }
    1423             :                     }
    1424           0 :                     if( nCode == KEY_SUBTRACT )
    1425             :                     {
    1426           0 :                         fGrowAmountX = -fGrowAmountX;
    1427           0 :                         fGrowAmountY = -fGrowAmountY;
    1428             :                     }
    1429             :                     bReturn = impl_moveOrResizeObject(
    1430           0 :                         m_aSelection.getSelectedCID(), CENTERED_RESIZE_OBJECT, fGrowAmountX, fGrowAmountY );
    1431           0 :                 }
    1432             :             }
    1433             :             // position
    1434           0 :             else if( nCode == KEY_LEFT  ||
    1435           0 :                      nCode == KEY_RIGHT ||
    1436           0 :                      nCode == KEY_UP ||
    1437             :                      nCode == KEY_DOWN )
    1438             :             {
    1439           0 :                 if( m_aSelection.isDragableObjectSelected() )
    1440             :                 {
    1441             :                     // default 1 mm
    1442           0 :                     double fShiftAmountX = 100.0;
    1443           0 :                     double fShiftAmountY = 100.0;
    1444           0 :                     if( bAlternate && m_pChartWindow )
    1445             :                     {
    1446             :                         // together with Alt-key: 1 px
    1447           0 :                         SolarMutexGuard aGuard;
    1448           0 :                         if(m_pChartWindow)
    1449             :                         {
    1450           0 :                             Size aPixelSize = m_pChartWindow->PixelToLogic( Size( 1, 1 ));
    1451           0 :                             fShiftAmountX = static_cast< double >( aPixelSize.Width());
    1452           0 :                             fShiftAmountY = static_cast< double >( aPixelSize.Height());
    1453           0 :                         }
    1454             :                     }
    1455           0 :                     switch( nCode )
    1456             :                     {
    1457             :                         case KEY_LEFT:
    1458           0 :                             fShiftAmountX = -fShiftAmountX;
    1459           0 :                             fShiftAmountY = 0.0;
    1460           0 :                             break;
    1461             :                         case KEY_RIGHT:
    1462           0 :                             fShiftAmountY = 0.0;
    1463           0 :                             break;
    1464             :                         case KEY_UP:
    1465           0 :                             fShiftAmountX = 0.0;
    1466           0 :                             fShiftAmountY = -fShiftAmountY;
    1467           0 :                             break;
    1468             :                         case KEY_DOWN:
    1469           0 :                             fShiftAmountX = 0.0;
    1470           0 :                             break;
    1471             :                     }
    1472           0 :                     if( !m_aSelection.getSelectedCID().isEmpty() )
    1473             :                     {
    1474             :                         //move chart objects
    1475             :                         bReturn = impl_moveOrResizeObject(
    1476           0 :                             m_aSelection.getSelectedCID(), MOVE_OBJECT, fShiftAmountX, fShiftAmountY );
    1477             :                     }
    1478             :                     else
    1479             :                     {
    1480             :                         //move additional shapes
    1481           0 :                         uno::Reference< drawing::XShape > xShape( m_aSelection.getSelectedAdditionalShape() );
    1482           0 :                         if( xShape.is() )
    1483             :                         {
    1484           0 :                             awt::Point aPos( xShape->getPosition() );
    1485           0 :                             awt::Size aSize( xShape->getSize() );
    1486           0 :                             awt::Size aPageSize( ChartModelHelper::getPageSize( getModel() ) );
    1487           0 :                             aPos.X = static_cast< long >( static_cast< double >( aPos.X ) + fShiftAmountX );
    1488           0 :                             aPos.Y = static_cast< long >( static_cast< double >( aPos.Y ) + fShiftAmountY );
    1489           0 :                             if( aPos.X + aSize.Width > aPageSize.Width )
    1490           0 :                                 aPos.X = aPageSize.Width - aSize.Width;
    1491           0 :                             if( aPos.X < 0 )
    1492           0 :                                 aPos.X = 0;
    1493           0 :                             if( aPos.Y + aSize.Height > aPageSize.Height )
    1494           0 :                                 aPos.Y = aPageSize.Height - aSize.Height;
    1495           0 :                             if( aPos.Y < 0 )
    1496           0 :                                 aPos.Y = 0;
    1497             : 
    1498           0 :                             xShape->setPosition( aPos );
    1499           0 :                         }
    1500             :                     }
    1501             :                 }
    1502             :             }
    1503             :         }
    1504             :     }
    1505             : 
    1506             :     // dumping the shape
    1507           0 :     if( !bReturn && bCtrl && nCode == KEY_F12)
    1508             :     {
    1509           0 :         uno::Reference< qa::XDumper > xChartModel( getModel(), uno::UNO_QUERY );
    1510           0 :         if(xChartModel.is())
    1511             :         {
    1512           0 :             OUString aDump = xChartModel->dump();
    1513           0 :             SAL_WARN("chart2", aDump);
    1514           0 :         }
    1515             :     }
    1516             : 
    1517             :     // text edit
    1518           0 :     if( ! bReturn &&
    1519             :         nCode == KEY_F2 )
    1520             :     {
    1521           0 :         if( OBJECTTYPE_TITLE == eObjectType )
    1522             :         {
    1523           0 :             executeDispatch_EditText();
    1524           0 :             bReturn = true;
    1525             :         }
    1526             :     }
    1527             : 
    1528             :     // deactivate inplace mode (this code should be unnecessary, but
    1529             :     // unfortunately is not)
    1530           0 :     if( ! bReturn &&
    1531             :         nCode == KEY_ESCAPE )
    1532             :     {
    1533           0 :         uno::Reference< frame::XDispatchHelper > xDispatchHelper( frame::DispatchHelper::create(m_xCC) );
    1534           0 :         uno::Sequence< beans::PropertyValue > aArgs;
    1535           0 :         xDispatchHelper->executeDispatch(
    1536             :             uno::Reference< frame::XDispatchProvider >( m_xFrame, uno::UNO_QUERY ),
    1537             :             ".uno:TerminateInplaceActivation",
    1538             :             "_parent",
    1539             :             frame::FrameSearchFlag::PARENT,
    1540           0 :             aArgs );
    1541           0 :         bReturn = true;
    1542             :     }
    1543             : 
    1544           0 :     if( ! bReturn &&
    1545           0 :         (nCode == KEY_DELETE || nCode == KEY_BACKSPACE ))
    1546             :     {
    1547           0 :         bReturn = executeDispatch_Delete();
    1548           0 :         if( ! bReturn )
    1549             :         {
    1550           0 :             SolarMutexGuard aGuard;
    1551           0 :             InfoBox( m_pChartWindow, SCH_RESSTR( STR_ACTION_NOTPOSSIBLE )).Execute();
    1552             :         }
    1553             :     }
    1554             : 
    1555           0 :     return bReturn;
    1556             : }
    1557             : 
    1558           0 : bool ChartController::requestQuickHelp(
    1559             :     ::Point aAtLogicPosition,
    1560             :     bool bIsBalloonHelp,
    1561             :     OUString & rOutQuickHelpText,
    1562             :     awt::Rectangle & rOutEqualRect )
    1563             : {
    1564           0 :     uno::Reference< frame::XModel > xChartModel;
    1565           0 :     if( m_aModel.is())
    1566           0 :         xChartModel.set( getModel() );
    1567           0 :     if( !xChartModel.is())
    1568           0 :         return false;
    1569             : 
    1570             :     // help text
    1571           0 :     OUString aCID;
    1572           0 :     if( m_pDrawViewWrapper )
    1573             :     {
    1574           0 :         aCID = SelectionHelper::getHitObjectCID(
    1575           0 :             aAtLogicPosition, *m_pDrawViewWrapper );
    1576             :     }
    1577           0 :     bool bResult( !aCID.isEmpty());
    1578             : 
    1579           0 :     if( bResult )
    1580             :     {
    1581             :         // get help text
    1582           0 :         rOutQuickHelpText = ObjectNameProvider::getHelpText( aCID, xChartModel, bIsBalloonHelp /* bVerbose */ );
    1583             : 
    1584             :         // set rectangle
    1585             :         ExplicitValueProvider * pValueProvider(
    1586           0 :             ExplicitValueProvider::getExplicitValueProvider( m_xChartView ));
    1587           0 :         if( pValueProvider )
    1588           0 :             rOutEqualRect = pValueProvider->getRectangleOfObject( aCID, true );
    1589             :     }
    1590             : 
    1591           0 :     return bResult;
    1592             : }
    1593             : 
    1594             : // XSelectionSupplier (optional interface)
    1595           0 :         sal_Bool SAL_CALL ChartController
    1596             : ::select( const uno::Any& rSelection )
    1597             :         throw( lang::IllegalArgumentException, std::exception )
    1598             : {
    1599           0 :     bool bSuccess = false;
    1600             : 
    1601           0 :     if ( rSelection.hasValue() )
    1602             :     {
    1603           0 :         const uno::Type& rType = rSelection.getValueType();
    1604           0 :         if ( rType == ::getCppuType( static_cast< const OUString* >( 0 ) ) )
    1605             :         {
    1606           0 :             OUString aNewCID;
    1607           0 :             if ( ( rSelection >>= aNewCID ) && m_aSelection.setSelection( aNewCID ) )
    1608             :             {
    1609           0 :                 bSuccess = true;
    1610           0 :             }
    1611             :         }
    1612           0 :         else if ( rType == ::getCppuType( static_cast< const uno::Reference< drawing::XShape >* >( 0 ) ) )
    1613             :         {
    1614           0 :             uno::Reference< drawing::XShape > xShape;
    1615           0 :             if ( ( rSelection >>= xShape ) && m_aSelection.setSelection( xShape ) )
    1616             :             {
    1617           0 :                 bSuccess = true;
    1618           0 :             }
    1619             :         }
    1620             :     }
    1621             :     else
    1622             :     {
    1623           0 :         if ( m_aSelection.hasSelection() )
    1624             :         {
    1625           0 :             m_aSelection.clearSelection();
    1626           0 :             bSuccess = true;
    1627             :         }
    1628             :     }
    1629             : 
    1630           0 :     if ( bSuccess )
    1631             :     {
    1632           0 :         SolarMutexGuard aGuard;
    1633           0 :         if ( m_pDrawViewWrapper && m_pDrawViewWrapper->IsTextEdit() )
    1634             :         {
    1635           0 :             this->EndTextEdit();
    1636             :         }
    1637           0 :         this->impl_selectObjectAndNotiy();
    1638           0 :         if ( m_pChartWindow )
    1639             :         {
    1640           0 :             m_pChartWindow->Invalidate();
    1641             :         }
    1642           0 :         return sal_True;
    1643             :     }
    1644             : 
    1645           0 :     return sal_False;
    1646             : }
    1647             : 
    1648        1930 :         uno::Any SAL_CALL ChartController
    1649             : ::getSelection() throw(uno::RuntimeException, std::exception)
    1650             : {
    1651        1930 :     uno::Any aReturn;
    1652        1930 :     if ( m_aSelection.hasSelection() )
    1653             :     {
    1654           0 :         OUString aCID( m_aSelection.getSelectedCID() );
    1655           0 :         if ( !aCID.isEmpty() )
    1656             :         {
    1657           0 :             aReturn = uno::makeAny( aCID );
    1658             :         }
    1659             :         else
    1660             :         {
    1661             :             // #i12587# support for shapes in chart
    1662           0 :             aReturn = uno::makeAny( m_aSelection.getSelectedAdditionalShape() );
    1663           0 :         }
    1664             :     }
    1665        1930 :     return aReturn;
    1666             : }
    1667             : 
    1668          34 :         void SAL_CALL ChartController
    1669             : ::addSelectionChangeListener( const uno::Reference<
    1670             :         view::XSelectionChangeListener > & xListener )
    1671             :         throw(uno::RuntimeException, std::exception)
    1672             : {
    1673          34 :     SolarMutexGuard aGuard;
    1674          34 :     if( impl_isDisposedOrSuspended() )//@todo? allow adding of listeners in suspend mode?
    1675          34 :         return; //behave passive if already disposed or suspended
    1676             : 
    1677             :     //--add listener
    1678          34 :     m_aLifeTimeManager.m_aListenerContainer.addInterface( ::getCppuType((const uno::Reference< view::XSelectionChangeListener >*)0), xListener );
    1679             : }
    1680             : 
    1681           0 :         void SAL_CALL ChartController
    1682             : ::removeSelectionChangeListener( const uno::Reference<
    1683             :         view::XSelectionChangeListener > & xListener )
    1684             :         throw(uno::RuntimeException, std::exception)
    1685             : {
    1686           0 :     SolarMutexGuard aGuard;
    1687           0 :     if( impl_isDisposedOrSuspended() ) //@todo? allow removing of listeners in suspend mode?
    1688           0 :         return; //behave passive if already disposed or suspended
    1689             : 
    1690             :     //--remove listener
    1691           0 :     m_aLifeTimeManager.m_aListenerContainer.removeInterface( ::getCppuType((const uno::Reference< view::XSelectionChangeListener >*)0), xListener );
    1692             : }
    1693             : 
    1694           0 :         void ChartController
    1695             : ::impl_notifySelectionChangeListeners()
    1696             : {
    1697             :     ::cppu::OInterfaceContainerHelper* pIC = m_aLifeTimeManager.m_aListenerContainer
    1698           0 :         .getContainer( ::getCppuType((const uno::Reference< view::XSelectionChangeListener >*)0) );
    1699           0 :     if( pIC )
    1700             :     {
    1701           0 :         uno::Reference< view::XSelectionSupplier > xSelectionSupplier(this);
    1702           0 :         lang::EventObject aEvent( xSelectionSupplier );
    1703           0 :         ::cppu::OInterfaceIteratorHelper aIt( *pIC );
    1704           0 :         while( aIt.hasMoreElements() )
    1705             :         {
    1706           0 :             uno::Reference< view::XSelectionChangeListener > xListener( aIt.next(), uno::UNO_QUERY );
    1707           0 :             if( xListener.is() )
    1708           0 :                 xListener->selectionChanged( aEvent );
    1709           0 :         }
    1710             :     }
    1711           0 : }
    1712             : 
    1713           0 : void ChartController::impl_selectObjectAndNotiy()
    1714             : {
    1715             :     {
    1716           0 :         SolarMutexGuard aGuard;
    1717           0 :         DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper;
    1718           0 :         if( pDrawViewWrapper )
    1719             :         {
    1720           0 :             pDrawViewWrapper->SetDragMode( m_eDragMode );
    1721           0 :             m_aSelection.applySelection( m_pDrawViewWrapper );
    1722           0 :         }
    1723             :     }
    1724           0 :     impl_notifySelectionChangeListeners();
    1725           0 : }
    1726             : 
    1727           0 : bool ChartController::impl_moveOrResizeObject(
    1728             :     const OUString & rCID,
    1729             :     eMoveOrResizeType eType,
    1730             :     double fAmountLogicX,
    1731             :     double fAmountLogicY )
    1732             : {
    1733           0 :     bool bResult = false;
    1734           0 :     bool bNeedShift = true;
    1735           0 :     bool bNeedResize = ( eType == CENTERED_RESIZE_OBJECT );
    1736             : 
    1737           0 :     uno::Reference< frame::XModel > xChartModel( getModel() );
    1738             :     uno::Reference< beans::XPropertySet > xObjProp(
    1739           0 :         ObjectIdentifier::getObjectPropertySet( rCID, xChartModel ));
    1740           0 :     if( xObjProp.is())
    1741             :     {
    1742           0 :         awt::Size aRefSize = ChartModelHelper::getPageSize( xChartModel );
    1743             : 
    1744           0 :         chart2::RelativePosition aRelPos;
    1745           0 :         chart2::RelativeSize     aRelSize;
    1746           0 :         bool bDeterminePos  = !(xObjProp->getPropertyValue( "RelativePosition") >>= aRelPos);
    1747           0 :         bool bDetermineSize = !bNeedResize || !(xObjProp->getPropertyValue( "RelativeSize") >>= aRelSize);
    1748             : 
    1749           0 :         if( ( bDeterminePos || bDetermineSize ) &&
    1750           0 :             ( aRefSize.Width > 0 && aRefSize.Height > 0 ) )
    1751             :         {
    1752             :             ExplicitValueProvider * pValueProvider(
    1753           0 :                 ExplicitValueProvider::getExplicitValueProvider( m_xChartView ));
    1754           0 :             if( pValueProvider )
    1755             :             {
    1756           0 :                 awt::Rectangle aRect( pValueProvider->getRectangleOfObject( rCID ));
    1757           0 :                 double fWidth = static_cast< double >( aRefSize.Width );
    1758           0 :                 double fHeight = static_cast< double >( aRefSize.Height );
    1759           0 :                 if( bDetermineSize )
    1760             :                 {
    1761           0 :                     aRelSize.Primary   = static_cast< double >( aRect.Width ) / fWidth;
    1762           0 :                     aRelSize.Secondary = static_cast< double >( aRect.Height ) / fHeight;
    1763             :                 }
    1764           0 :                 if( bDeterminePos )
    1765             :                 {
    1766           0 :                     if( bNeedResize && aRelSize.Primary > 0.0 && aRelSize.Secondary > 0.0 )
    1767             :                     {
    1768           0 :                         aRelPos.Primary   = (static_cast< double >( aRect.X ) / fWidth) +
    1769           0 :                             (aRelSize.Primary / 2.0);
    1770           0 :                         aRelPos.Secondary = (static_cast< double >( aRect.Y ) / fHeight) +
    1771           0 :                             (aRelSize.Secondary / 2.0);
    1772           0 :                         aRelPos.Anchor = drawing::Alignment_CENTER;
    1773             :                     }
    1774             :                     else
    1775             :                     {
    1776           0 :                         aRelPos.Primary   = static_cast< double >( aRect.X ) / fWidth;
    1777           0 :                         aRelPos.Secondary = static_cast< double >( aRect.Y ) / fHeight;
    1778           0 :                         aRelPos.Anchor = drawing::Alignment_TOP_LEFT;
    1779             :                     }
    1780             :                 }
    1781             :             }
    1782             :         }
    1783             : 
    1784           0 :         if( eType == CENTERED_RESIZE_OBJECT )
    1785           0 :             bResult = lcl_GrowAndShiftLogic( aRelPos, aRelSize, aRefSize, fAmountLogicX, fAmountLogicY );
    1786           0 :         else if( eType == MOVE_OBJECT )
    1787           0 :             bResult = lcl_MoveObjectLogic( aRelPos, aRelSize, aRefSize, fAmountLogicX, fAmountLogicY );
    1788             : 
    1789           0 :         if( bResult )
    1790             :         {
    1791           0 :             ActionDescriptionProvider::ActionType eActionType(ActionDescriptionProvider::MOVE);
    1792           0 :             if( bNeedResize )
    1793           0 :                 eActionType = ActionDescriptionProvider::RESIZE;
    1794             : 
    1795           0 :             ObjectType eObjectType = ObjectIdentifier::getObjectType( rCID );
    1796             :             UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription(
    1797           0 :                     eActionType, ObjectNameProvider::getName( eObjectType )), m_xUndoManager );
    1798             :             {
    1799           0 :                 ControllerLockGuardUNO aCLGuard( xChartModel );
    1800           0 :                 if( bNeedShift )
    1801           0 :                     xObjProp->setPropertyValue( "RelativePosition", uno::makeAny( aRelPos ));
    1802           0 :                 if( bNeedResize || (eObjectType == OBJECTTYPE_DIAGRAM) )//Also set an explicat size at the diagram when an explicit position is set
    1803           0 :                     xObjProp->setPropertyValue( "RelativeSize", uno::makeAny( aRelSize ));
    1804             :             }
    1805           0 :             aUndoGuard.commit();
    1806             :         }
    1807             :     }
    1808           0 :     return bResult;
    1809             : }
    1810             : 
    1811           0 : bool ChartController::impl_DragDataPoint( const OUString & rCID, double fAdditionalOffset )
    1812             : {
    1813           0 :     bool bResult = false;
    1814           0 :     if( fAdditionalOffset < -1.0 || fAdditionalOffset > 1.0 || fAdditionalOffset == 0.0 )
    1815           0 :         return bResult;
    1816             : 
    1817           0 :     sal_Int32 nDataPointIndex = ObjectIdentifier::getIndexFromParticleOrCID( rCID );
    1818             :     uno::Reference< chart2::XDataSeries > xSeries(
    1819           0 :         ObjectIdentifier::getDataSeriesForCID( rCID, getModel() ));
    1820           0 :     if( xSeries.is())
    1821             :     {
    1822             :         try
    1823             :         {
    1824           0 :             uno::Reference< beans::XPropertySet > xPointProp( xSeries->getDataPointByIndex( nDataPointIndex ));
    1825           0 :             double fOffset = 0.0;
    1826           0 :             if( xPointProp.is() &&
    1827           0 :                 (xPointProp->getPropertyValue( "Offset" ) >>= fOffset ) &&
    1828           0 :                 (( fAdditionalOffset > 0.0 && fOffset < 1.0 ) || (fOffset > 0.0)) )
    1829             :             {
    1830           0 :                 fOffset += fAdditionalOffset;
    1831           0 :                 if( fOffset > 1.0 )
    1832           0 :                     fOffset = 1.0;
    1833           0 :                 else if( fOffset < 0.0 )
    1834           0 :                     fOffset = 0.0;
    1835           0 :                 xPointProp->setPropertyValue( "Offset", uno::makeAny( fOffset ));
    1836           0 :                 bResult = true;
    1837           0 :             }
    1838             :         }
    1839           0 :         catch( const uno::Exception & ex )
    1840             :         {
    1841             :             ASSERT_EXCEPTION( ex );
    1842             :         }
    1843             :     }
    1844             : 
    1845           0 :     return bResult;
    1846             : }
    1847             : 
    1848           0 : void ChartController::impl_SetMousePointer( const MouseEvent & rEvent )
    1849             : {
    1850           0 :     SolarMutexGuard aGuard;
    1851             : 
    1852           0 :     if (!m_pDrawViewWrapper || !m_pChartWindow)
    1853           0 :         return;
    1854             : 
    1855           0 :     Point aMousePos( m_pChartWindow->PixelToLogic( rEvent.GetPosPixel()));
    1856           0 :     sal_uInt16 nModifier = rEvent.GetModifier();
    1857           0 :     sal_Bool bLeftDown = rEvent.IsLeft();
    1858             : 
    1859           0 :     if ( m_pDrawViewWrapper->IsTextEdit() )
    1860             :     {
    1861           0 :         if( m_pDrawViewWrapper->IsTextEditHit( aMousePos, HITPIX) )
    1862             :         {
    1863             :             m_pChartWindow->SetPointer( m_pDrawViewWrapper->GetPreferredPointer(
    1864           0 :                 aMousePos, m_pChartWindow, nModifier, bLeftDown ) );
    1865           0 :             return;
    1866             :         }
    1867             :     }
    1868           0 :     else if( m_pDrawViewWrapper->IsAction() )
    1869             :     {
    1870           0 :         return;//don't change pointer during running action
    1871             :     }
    1872             : 
    1873           0 :     SdrHdl* pHitSelectionHdl = 0;
    1874           0 :     if( m_aSelection.isResizeableObjectSelected() )
    1875           0 :         pHitSelectionHdl = m_pDrawViewWrapper->PickHandle( aMousePos );
    1876             : 
    1877           0 :     if( pHitSelectionHdl )
    1878             :     {
    1879             :         Pointer aPointer = m_pDrawViewWrapper->GetPreferredPointer(
    1880           0 :             aMousePos, m_pChartWindow, nModifier, bLeftDown );
    1881           0 :         bool bForceArrowPointer = false;
    1882             : 
    1883           0 :         ObjectIdentifier aOID( m_aSelection.getSelectedOID() );
    1884             : 
    1885           0 :         switch( aPointer.GetStyle())
    1886             :         {
    1887             :             case POINTER_NSIZE:
    1888             :             case POINTER_SSIZE:
    1889             :             case POINTER_WSIZE:
    1890             :             case POINTER_ESIZE:
    1891             :             case POINTER_NWSIZE:
    1892             :             case POINTER_NESIZE:
    1893             :             case POINTER_SWSIZE:
    1894             :             case POINTER_SESIZE:
    1895           0 :                 if( ! m_aSelection.isResizeableObjectSelected() )
    1896           0 :                     bForceArrowPointer = true;
    1897           0 :                 break;
    1898             :             case POINTER_MOVE:
    1899           0 :                 if ( !aOID.isDragableObject() )
    1900           0 :                     bForceArrowPointer = true;
    1901           0 :                 break;
    1902             :             case POINTER_MOVEPOINT:
    1903             :             case POINTER_MOVEBEZIERWEIGHT:
    1904             :                 // there is no point-editing in a chart
    1905             :                 // the POINTER_MOVEBEZIERWEIGHT appears in 3d data points
    1906           0 :                 bForceArrowPointer = true;
    1907           0 :                 break;
    1908             :             default:
    1909           0 :                 break;
    1910             :         }
    1911             : 
    1912           0 :         if( bForceArrowPointer )
    1913           0 :             m_pChartWindow->SetPointer( Pointer( POINTER_ARROW ));
    1914             :         else
    1915           0 :             m_pChartWindow->SetPointer( aPointer );
    1916             : 
    1917           0 :         return;
    1918             :     }
    1919             : 
    1920             :     // #i12587# support for shapes in chart
    1921           0 :     if ( m_eDrawMode == CHARTDRAW_INSERT &&
    1922           0 :          ( !m_pDrawViewWrapper->IsMarkedHit( aMousePos ) || !m_aSelection.isDragableObjectSelected() ) )
    1923             :     {
    1924           0 :         PointerStyle ePointerStyle = POINTER_DRAW_RECT;
    1925           0 :         SdrObjKind eKind = static_cast< SdrObjKind >( m_pDrawViewWrapper->GetCurrentObjIdentifier() );
    1926           0 :         switch ( eKind )
    1927             :         {
    1928             :             case OBJ_LINE:
    1929             :                 {
    1930           0 :                     ePointerStyle = POINTER_DRAW_LINE;
    1931             :                 }
    1932           0 :                 break;
    1933             :             case OBJ_RECT:
    1934             :             case OBJ_CUSTOMSHAPE:
    1935             :                 {
    1936           0 :                     ePointerStyle = POINTER_DRAW_RECT;
    1937             :                 }
    1938           0 :                 break;
    1939             :             case OBJ_CIRC:
    1940             :                 {
    1941           0 :                     ePointerStyle = POINTER_DRAW_ELLIPSE;
    1942             :                 }
    1943           0 :                 break;
    1944             :             case OBJ_FREELINE:
    1945             :                 {
    1946           0 :                     ePointerStyle = POINTER_DRAW_POLYGON;
    1947             :                 }
    1948           0 :                 break;
    1949             :             case OBJ_TEXT:
    1950             :                 {
    1951           0 :                     ePointerStyle = POINTER_DRAW_TEXT;
    1952             :                 }
    1953           0 :                 break;
    1954             :             case OBJ_CAPTION:
    1955             :                 {
    1956           0 :                     ePointerStyle = POINTER_DRAW_CAPTION;
    1957             :                 }
    1958           0 :                 break;
    1959             :             default:
    1960             :                 {
    1961           0 :                     ePointerStyle = POINTER_DRAW_RECT;
    1962             :                 }
    1963           0 :                 break;
    1964             :         }
    1965           0 :         m_pChartWindow->SetPointer( Pointer( ePointerStyle ) );
    1966           0 :         return;
    1967             :     }
    1968             : 
    1969             :     OUString aHitObjectCID(
    1970             :         SelectionHelper::getHitObjectCID(
    1971           0 :             aMousePos, *m_pDrawViewWrapper, true /*bGetDiagramInsteadOf_Wall*/ ));
    1972             : 
    1973           0 :     if( m_pDrawViewWrapper->IsTextEdit() )
    1974             :     {
    1975           0 :         if( aHitObjectCID.equals(m_aSelection.getSelectedCID()) )
    1976             :         {
    1977           0 :             m_pChartWindow->SetPointer( Pointer( POINTER_ARROW ));
    1978           0 :             return;
    1979             :         }
    1980             :     }
    1981             : 
    1982           0 :     if( aHitObjectCID.isEmpty() )
    1983             :     {
    1984             :         //additional shape was hit
    1985           0 :         m_pChartWindow->SetPointer( POINTER_MOVE );
    1986             :     }
    1987           0 :     else if( ObjectIdentifier::isDragableObject( aHitObjectCID ) )
    1988             :     {
    1989           0 :         if( (m_eDragMode == SDRDRAG_ROTATE)
    1990           0 :             && SelectionHelper::isRotateableObject( aHitObjectCID
    1991           0 :                 , getModel() ) )
    1992           0 :             m_pChartWindow->SetPointer( Pointer( POINTER_ROTATE ) );
    1993             :         else
    1994             :         {
    1995           0 :             ObjectType eHitObjectType = ObjectIdentifier::getObjectType( aHitObjectCID );
    1996           0 :             if( eHitObjectType == OBJECTTYPE_DATA_POINT )
    1997             :             {
    1998           0 :                 if( !ObjectIdentifier::areSiblings(aHitObjectCID,m_aSelection.getSelectedCID())
    1999           0 :                     && !ObjectIdentifier::areIdenticalObjects(aHitObjectCID,m_aSelection.getSelectedCID()) )
    2000             :                 {
    2001           0 :                     m_pChartWindow->SetPointer( Pointer( POINTER_ARROW ));
    2002           0 :                     return;
    2003             :                 }
    2004             :             }
    2005           0 :             m_pChartWindow->SetPointer( POINTER_MOVE );
    2006             :         }
    2007             :     }
    2008             :     else
    2009           0 :         m_pChartWindow->SetPointer( Pointer( POINTER_ARROW ));
    2010             : }
    2011             : 
    2012             : } //namespace chart
    2013             : 
    2014             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10