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

Generated by: LCOV version 1.10