LCOV - code coverage report
Current view: top level - chart2/source/controller/main - DragMethod_PieSegment.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 67 0.0 %
Date: 2012-08-25 Functions: 0 9 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 88 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * This file is part of the LibreOffice project.
       4                 :            :  *
       5                 :            :  * This Source Code Form is subject to the terms of the Mozilla Public
       6                 :            :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7                 :            :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8                 :            :  *
       9                 :            :  * This file incorporates work covered by the following license notice:
      10                 :            :  *
      11                 :            :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12                 :            :  *   contributor license agreements. See the NOTICE file distributed
      13                 :            :  *   with this work for additional information regarding copyright
      14                 :            :  *   ownership. The ASF licenses this file to you under the Apache
      15                 :            :  *   License, Version 2.0 (the "License"); you may not use this file
      16                 :            :  *   except in compliance with the License. You may obtain a copy of
      17                 :            :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18                 :            :  */
      19                 :            : 
      20                 :            : 
      21                 :            : #include "DragMethod_PieSegment.hxx"
      22                 :            : 
      23                 :            : #include "Strings.hrc"
      24                 :            : #include "ResId.hxx"
      25                 :            : #include "macros.hxx"
      26                 :            : #include "ObjectIdentifier.hxx"
      27                 :            : #include <rtl/math.hxx>
      28                 :            : #include <svx/svdpagv.hxx>
      29                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      30                 :            : #include <basegfx/matrix/b2dhommatrix.hxx>
      31                 :            : 
      32                 :            : //.............................................................................
      33                 :            : namespace chart
      34                 :            : {
      35                 :            : //.............................................................................
      36                 :            : 
      37                 :            : using namespace ::com::sun::star;
      38                 :            : using ::com::sun::star::uno::Reference;
      39                 :            : using ::basegfx::B2DVector;
      40                 :            : 
      41                 :          0 : DragMethod_PieSegment::DragMethod_PieSegment( DrawViewWrapper& rDrawViewWrapper
      42                 :            :                                              , const rtl::OUString& rObjectCID
      43                 :            :                                              , const Reference< frame::XModel >& xChartModel )
      44                 :            :     : DragMethod_Base( rDrawViewWrapper, rObjectCID, xChartModel )
      45                 :            :     , m_aStartVector(100.0,100.0)
      46                 :            :     , m_fInitialOffset(0.0)
      47                 :            :     , m_fAdditionalOffset(0.0)
      48                 :            :     , m_aDragDirection(1000.0,1000.0)
      49                 :          0 :     , m_fDragRange( 1.0 )
      50                 :            : {
      51         [ #  # ]:          0 :     rtl::OUString aParameter( ObjectIdentifier::getDragParameterString( m_aObjectCID ) );
      52                 :            : 
      53                 :          0 :     sal_Int32 nOffsetPercent(0);
      54                 :          0 :     awt::Point aMinimumPosition(0,0);
      55                 :          0 :     awt::Point aMaximumPosition(0,0);
      56                 :            : 
      57                 :            :     ObjectIdentifier::parsePieSegmentDragParameterString(
      58         [ #  # ]:          0 :           aParameter, nOffsetPercent, aMinimumPosition, aMaximumPosition );
      59                 :            : 
      60                 :          0 :     m_fInitialOffset = nOffsetPercent / 100.0;
      61         [ #  # ]:          0 :     if( m_fInitialOffset < 0.0 )
      62                 :          0 :         m_fInitialOffset = 0.0;
      63         [ #  # ]:          0 :     if( m_fInitialOffset > 1.0 )
      64                 :          0 :         m_fInitialOffset = 1.0;
      65                 :          0 :     B2DVector aMinVector( aMinimumPosition.X, aMinimumPosition.Y );
      66                 :          0 :     B2DVector aMaxVector( aMaximumPosition.X, aMaximumPosition.Y );
      67         [ #  # ]:          0 :     m_aDragDirection = aMaxVector - aMinVector;
      68         [ #  # ]:          0 :     m_fDragRange = m_aDragDirection.scalar( m_aDragDirection );
      69         [ #  # ]:          0 :     if( ::rtl::math::approxEqual( m_fDragRange, 0.0 ) )
      70                 :          0 :         m_fDragRange = 1.0;
      71                 :          0 : }
      72                 :          0 : DragMethod_PieSegment::~DragMethod_PieSegment()
      73                 :            : {
      74         [ #  # ]:          0 : }
      75                 :          0 : void DragMethod_PieSegment::TakeSdrDragComment(String& rStr) const
      76                 :            : {
      77 [ #  # ][ #  # ]:          0 :     rStr = SCH_RESSTR(STR_STATUS_PIE_SEGMENT_EXPLODED);
      78 [ #  # ][ #  # ]:          0 :     rStr.SearchAndReplaceAscii( "%PERCENTVALUE", rtl::OUString::valueOf( static_cast<sal_Int32>((m_fAdditionalOffset+m_fInitialOffset)*100.0) ));
                 [ #  # ]
      79                 :          0 : }
      80                 :          0 : bool DragMethod_PieSegment::BeginSdrDrag()
      81                 :            : {
      82         [ #  # ]:          0 :     Point aStart( DragStat().GetStart() );
      83         [ #  # ]:          0 :     m_aStartVector = B2DVector( aStart.X(), aStart.Y() );
      84         [ #  # ]:          0 :     Show();
      85                 :          0 :     return true;
      86                 :            : }
      87                 :          0 : void DragMethod_PieSegment::MoveSdrDrag(const Point& rPnt)
      88                 :            : {
      89         [ #  # ]:          0 :     if( DragStat().CheckMinMoved(rPnt) )
      90                 :            :     {
      91                 :            :         //calculate new offset
      92                 :          0 :         B2DVector aShiftVector(( B2DVector( rPnt.X(), rPnt.Y() ) - m_aStartVector ));
      93         [ #  # ]:          0 :         m_fAdditionalOffset = m_aDragDirection.scalar( aShiftVector )/m_fDragRange; // projection
      94                 :            : 
      95         [ #  # ]:          0 :         if( m_fAdditionalOffset < -m_fInitialOffset )
      96                 :          0 :             m_fAdditionalOffset = -m_fInitialOffset;
      97         [ #  # ]:          0 :         else if( m_fAdditionalOffset > (1.0-m_fInitialOffset) )
      98                 :          0 :             m_fAdditionalOffset = 1.0 - m_fInitialOffset;
      99                 :            : 
     100                 :          0 :         B2DVector aNewPosVector = m_aStartVector + (m_aDragDirection * m_fAdditionalOffset);
     101                 :          0 :         Point aNewPos = Point( (long)(aNewPosVector.getX()), (long)(aNewPosVector.getY()) );
     102 [ #  # ][ #  # ]:          0 :         if( aNewPos != DragStat().GetNow() )
     103                 :            :         {
     104         [ #  # ]:          0 :             Hide();
     105         [ #  # ]:          0 :             DragStat().NextMove( aNewPos );
     106         [ #  # ]:          0 :             Show();
     107                 :          0 :         }
     108                 :            :     }
     109                 :          0 : }
     110                 :          0 : bool DragMethod_PieSegment::EndSdrDrag(bool /*bCopy*/)
     111                 :            : {
     112                 :          0 :     Hide();
     113                 :            : 
     114                 :            :     try
     115                 :            :     {
     116         [ #  # ]:          0 :         Reference< frame::XModel > xChartModel( this->getChartModel() );
     117         [ #  # ]:          0 :         if( xChartModel.is() )
     118                 :            :         {
     119                 :            :             Reference< beans::XPropertySet > xPointProperties(
     120         [ #  # ]:          0 :                 ObjectIdentifier::getObjectPropertySet( m_aObjectCID, xChartModel ) );
     121         [ #  # ]:          0 :             if( xPointProperties.is() )
     122 [ #  # ][ #  # ]:          0 :                 xPointProperties->setPropertyValue( C2U( "Offset" ), uno::makeAny( m_fAdditionalOffset+m_fInitialOffset ));
         [ #  # ][ #  # ]
     123         [ #  # ]:          0 :         }
     124                 :            :     }
     125                 :          0 :     catch( const uno::Exception & ex )
     126                 :            :     {
     127                 :            :         ASSERT_EXCEPTION( ex );
     128                 :            :     }
     129                 :            : 
     130                 :          0 :     return true;
     131                 :            : }
     132                 :          0 : basegfx::B2DHomMatrix DragMethod_PieSegment::getCurrentTransformation()
     133                 :            : {
     134                 :          0 :     basegfx::B2DHomMatrix aRetval;
     135                 :            : 
     136 [ #  # ][ #  # ]:          0 :     aRetval.translate(DragStat().GetDX(), DragStat().GetDY());
                 [ #  # ]
     137                 :            : 
     138                 :          0 :     return aRetval;
     139                 :            : }
     140                 :          0 : void DragMethod_PieSegment::createSdrDragEntries()
     141                 :            : {
     142                 :          0 :     SdrObject* pObj = m_rDrawViewWrapper.getSelectedObject();
     143                 :          0 :     SdrPageView* pPV = m_rDrawViewWrapper.GetPageView();
     144                 :            : 
     145 [ #  # ][ #  # ]:          0 :     if( pObj && pPV )
     146                 :            :     {
     147         [ #  # ]:          0 :         const basegfx::B2DPolyPolygon aNewPolyPolygon(pObj->TakeXorPoly());
     148 [ #  # ][ #  # ]:          0 :         addSdrDragEntry(new SdrDragEntryPolyPolygon(aNewPolyPolygon));
         [ #  # ][ #  # ]
     149                 :            :     }
     150                 :          0 : }
     151                 :            : //.............................................................................
     152                 :            : } //namespace chart
     153                 :            : //.............................................................................
     154                 :            : 
     155                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10